Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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 version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 width="800px" height="500px" viewBox="0 0 800 500" style="enable-background:new 0 0 800 500;" xml:space="preserve">
<path id="path" style="fill:none;stroke:#000000;stroke-miterlimit:10;" d="M0,0c0,0,14,184,157,184V86h173c0,0,105-3,105,93"/>
</svg>
<div class="box red" id="redBox"></div>

  

              
            
!

CSS

              
                body {
  font-family:sans-serif;
  margin:0; 
  background:#ccc;
}

h1 {
  margin: 5px 0;
}
h3 {
  margin:0;
  font-size:16px;
}
.demo {
  width:600px;
  height:120px;
  background-color:black;
}

.box {
  width:50px;
  height:50px;
  position:relative;
  margin-bottom:2px;
}

.red {
  background-color:red;
}

.blue {
  background-color:blue;
}

.nav {
  width:600px;
  background-color:#ccc;
  text-align:right;
}

button {
  padding:10px;
  margin:10px;
}

svg {
  position:absolute;
}
              
            
!

JS

              
                //points exported from DrawScript : Bezier Points Array (anchor, control, control, anchor)
var data = Snap.path.toCubic(document.getElementById("path").getAttribute('d'))
    dataLength = data.length,
    points = [], //holds our series of x/y values for anchors and control points,
    pointsString = data.toString();

// convert cubic data to GSAP bezier
for (var i = 0; i < dataLength; i++) {
  var seg = data[i];
  if (seg[0] === "M") { // move (starts the path)
    var point = {};
    point.x = seg[1];
    point.y = seg[2];
    points.push(point);
  } else { // seg[0] === "C" (Snap.path.toCubic should return only curves after first point)
    for (var j = 1; j < 6; j+=2) {
      var point = {};
      point.x = seg[j];
      point.y = seg[j+1];
      points.push(point);
    }
  }
}

//make the tween
var tween = TweenMax.to("#redBox", 3, {bezier:{type:"cubic", values:points}, force3D:true, ease:Power0.easeNone});

$("#redBox").click(function(){
  tween.restart();
})

console.log(pointsString)
              
            
!
999px

Console