Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <svg id="svg" width="100%" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1400 480">
  <path class="path" d="M0,492.2C118,455,115.9,206.38,276.35,279,386.24,328.68,443.8,201.79,476.5,82.74,543.22,322.14,704,26,871.15,0"/>
</svg>
<div id="data">M0,492.2C118,455,115.9,206.38,276.35,279,386.24,328.68,443.8,201.79,476.5,82.74,543.22,322.14,704,26,871.15,0</div>
              
            
!

CSS

              
                .path {
  stroke: red;
  stroke-width: 5;
  fill: none;
}

svg {
  overflow: visible;
}
#data {
  color: white;
  position: fixed;
  bottom: 10px;
  left: 40px;
  right: 40px;
  text-align: center;
}
body {
  background-color: black;
  font-family: monospace;
  font-size: 1.4em;
}
              
            
!

JS

              
                //just pass in an SVG path and BOOM, it's editable. 
PathEditor.create(".path", {draggable:true, selected:true, onUpdate:displayData, handleSize:6});

//this is just to display the path data
var data = document.getElementById("data");
function displayData(d) {
  data.innerHTML = d;
}
/* 
Features/Notes:

- ALT-click anywhere along the path to add a point
- ALT-click on an existing point to toggle between smooth and corner modes (smooth means the handles are linked). A circle indicates it's smooth, a square indicates a corner.
- ALT-drag a smooth handle to break its link to the opposite handle (to make it a corner). 
- SHIFT-click anchors to add/remove them to/from the selection.
- UNDO (CTRL-Z or CMD-Z) up to 30 times
- Rounds all values to 3 decimal places for cleaner values
- Select an anchor and hit the DELETE key to remove it.
- onUpdate callback passes the new data string as the only paramer.
- Hs an instance.getNormalizedSVG(height, originY, shorten, onEaseError) that normalizes all the points in the path to be based on 0-1, scaling down from whatever height you define (so that y values can exceed the top/bottom). If "shorten" is true, and the path only contains a single segment, it'll chop off the beginning/ending values and only leave the control points. [0,0, 1,1, 2,2, 3,3] would become [1,1, 2,2]. 
- Roughly 8.5kb gzipped and minified (so far)
- Has some super-useful utility functions like: 
    - PathEditor.simplifySVG(path, {tolerance:3, cornerThreshold:90}). (cornerThreshold is the angle in degrees under which a bend is considered a corner and should be sharp) 
    - PathEditor.simplifyPoints(pointsArray, tolerance) feed in an array of points like [x, y, x, y,...] and a tolerance and it'll return a simplified array accordingly
    - PathEditor.pointsToBezier(points, tolerance, cornerThreshold, curviness); feed in an array of points like [x, y, x, y,...] and it'll draw cubic Bezier curves through those points and return an array of cubic bezier points, like [x, y, x, y,...] (anchor, control point, control point, anchor, etc.)
*/
              
            
!
999px

Console