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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <canvas id="canvas"></canvas>
<svg style="display:none" >
  <path id="hippo" d="M149,245c2.7-36.7,16.11-69.08,40.1-97.06c27.04-31.6,60.92-47.39,101.63-47.39c15.48,0,38.48,2.45,69.02,7.29 c30.54,4.89,53.53,7.28,69.03,7.28c23.69,0,57.87,8.85,102.53,26.48c7.91,3.01,17.47,11.24,28.7,24.59 c6.38,7.89,16.26,19.77,29.62,35.57c3.04,2.14,7,5.32,11.86,9.6c4.86,4.22,8.19,6.06,10,5.46c0.62-1.84,2.15-4.4,4.58-7.74 c1.21-1.23,1.96-1.83,2.26-1.83c0.93,0.61,1.83,1.21,2.75,1.83c0.91,0.62,1.21,2.42,0.91,5.46c-0.62,5.47-0.91,7.14-0.91,5	c-0.33,3.06-0.76,5.01-1.37,5.95c-3.95,6.67-5.48,11.85-4.55,15.47c0.92,3.32,3.77,8.67,8.64,15.96c4.87,7.29,7.59,12.76,8.19,16.4 c-0.3,2.73-0.43,7.12-0.43,13.21l-4.57,11.38c0,8.51,9.86,23.11,29.62,43.78c9.44,4.22,14.12,18.83,14.12,43.71 c0,19.47-16.09,29.17-48.27,29.17c-4.26,0-8.81-0.13-13.68-0.47c-3.34-1.2-8.2-2.56-14.58-4.07c-7.59-0.93-12.76-3.49-15.48-7.77 c-4.88-6.95-12.78-13.51-23.71-19.58c-1.82-0.88-4.48-4.22-7.98-10.02c-3.5-5.77-6.61-9.42-9.33-10.95 c-2.72-1.49-6.68-1.81-11.86-0.88c-8.81,1.49-13.68,2.26-14.57,2.26c-2.14,0-5.25-0.6-9.34-1.83c-4.11-1.21-7.05-1.83-8.89-1.83 c-2.11,9.73-2.59,19.15-1.36,28.25c0.3,2.45,1.83,4.43,4.56,5.92c4.27,3.05,6.53,4.71,6.85,5.05c2.72,2.11,5.61,5.61,8.64,10.45 c0.62,1.85-0.52,4.95-3.42,9.34c-2.89,4.41-5.22,7.01-7.06,7.74c-1.81,0.79-5.77,1.18-11.85,1.18c-8.82,0-29.45-2.45-30.98-2.73 c-7.59-1.53-14.13-3.94-19.58-7.3c-2.76-1.81-5.91-10.33-9.56-25.52c-3.68-16.41-6.72-26.27-9.14-29.64 c-0.6-0.9-1.36-1.33-2.26-1.33c-1.53,0-4.05,1.49-7.53,4.56c-3.49,2.99-5.86,4.65-7.05,5.01c-4.24,17.9-6.4,26.4-6.4,25.47 c0,7.01,1.97,12.89,5.92,17.77c3.94,4.86,8.06,9.57,12.32,14.11c5.16,5.77,7.74,10.78,7.74,15.04c0,2.41-0.75,4.52-2.28,6.37 c-6.38,7.89-17.02,11.85-31.9,11.85c-16.71,0-27.64-2.28-32.79-6.84c-6.7-5.77-10.95-11.86-12.76-18.2 c-0.3-1.53-1.05-6.09-2.28-13.68c-0.61-4.58-1.98-7.29-4.08-8.18c-6.1-0.92-13.69-2.58-22.78-5.01c-1.84-1.21-3.81-4.26-5.94-9.12 c-3.93-9.4-6.83-15.79-8.66-19.13c-9.13-4.56-23.7-9.7-43.76-15.45c-0.92,1.83-1.35,4.37-1.35,7.72c3.34,4.26,8.34,10.8,15.03,19.58 c5.47,7.29,8.2,14.3,8.2,20.96c0,12.78-8.2,19.13-24.61,19.13c-12.45,0-20.96-0.88-25.52-2.71c-6.67-2.73-12.29-9.14-16.85-19.13 c-7.6-16.74-11.85-26.16-12.76-28.27c-4.87-11.23-8.2-21.13-10.01-29.65c-1.23-6.05-3.06-15.35-5.49-27.8 c-2.12-10.3-5.46-18.36-10.01-24.13C155.33,279.36,147.5,260.6,149,245z"/>
  
  <path id="circle" d="M490.1,280.649 c0,44.459-36.041,80.5-80.5,80.5s-80.5-36.041-80.5-80.5s36.041-80.5,80.5-80.5S490.1,236.19,490.1,280.649z" />
  
  <path id="star" d="M409.6,198.066l26.833,54.369l60,8.719l-43.417,42.321l10.249,59.758L409.6,335.019 l-53.666,28.214l10.249-59.758l-43.417-42.321l60-8.719L409.6,198.066z" />
  
  <path id="elephant" d="M446.47,99.67c12.1,0,23.83,7,35.23,20.99c11.38,13.99,17.97,20.99,19.76,20.99h17.12 c37,0,65.65,18.52,85.96,55.55c5.35,10.37,13.52,25.59,24.58,45.7c11.01,20.14,23.86,35.01,38.46,44.63 c16.37,10.69,32.92,16.59,49.64,17.63c7.82,0.36,16.39-1.07,25.66-4.3c8.19-3.58,16.36-7.17,24.54-10.75l5.34,11.86 c-26.34,20.21-51.44,30.64-75.3,31.36c-25.62,0.71-53.23-5.51-82.76-18.64c25.26,29.2,47,47.01,65.16,53.39l-4.27,4.3	c-32.04-5.7-61.61-22.1-88.65-49.15c0,0-22.7,15.71-25.37,17.3c-2.67,1.6-3.85,2.91-3.49,3.98c1.43,4.63,8.74,16,21.91,34.06	c13.17,18.13,19.76,27.71,19.76,28.75c0,3.2-4.1,6.38-12.29,9.59c-8.18,3.19-12.62,6.75-13.33,10.65c-0.72,3.2,0.33,7.11,3.2,11.71	c2.83,4.63,4.26,7.43,4.26,8.53c0,7.08-6.23,11.51-18.67,13.3c-2.16,0.33-8.94,0.53-20.31,0.53c-21.35,0-36.67-4.8-45.93-14.35	c-7.47-8.15-13.36-23.05-17.64-44.66c-1.43-7.43-3.91-20.73-7.47-39.9c-36.31,9.25-73.7,13.89-112.17,13.89	c-23.51,0-48.96-1.76-76.38-5.34c4.64,11.76,11.22,31.36,19.8,58.77c-17.81-2.5-39.19-6.05-64.09-10.69	c-11.06,16.72-20.51,24.74-28.33,24.03c-13.89-1.05-33.84-7.99-59.82-20.8c-6.42-3.2-9.61-8.02-9.61-14.44	c0-6.39,4.99-18.16,14.96-35.24c9.95-17.08,15.29-29.01,16.01-35.79c0.72-6.07-1.04-14.4-5.31-25.1	c-5.34-13.89-11.22-40.06-11.22-40.06c-16.39,17.8-31.35,30.8-44.88,38.99c-15.68,9.61-34.2,15.87-55.55,18.67	c-4.27-4.24-7.11-6.38-8.54-6.38c26.34-11.41,52.35-29.38,77.97-53.96c1.08-1.07,7.82-5.86,20.31-14.44	c7.1-4.62,11.37-10.1,12.81-16.52c8.89-35.6,27.05-60.73,54.46-75.34c22.43-11.74,53.95-17.6,94.53-17.6	c18.52,0,36.15,1.24,52.88,3.72c7.83,2.15,20.31,4.66,37.39,7.49c1.43-14.17,6.42-26.75,14.96-37.74 C421.38,106.06,432.95,99.67,446.47,99.67z" />
</svg>
              
            
!

CSS

              
                body {
  background: #1d1d1d;
}

#canvas {
  background: #1d1d1d;
  position: fixed;
  top: 0;
  left: 0;
}
              
            
!

JS

              
                var canvas  = document.querySelector("canvas");
var ctx = canvas.getContext("2d");
var vw = canvas.width  = window.innerWidth;
var vh = canvas.height = window.innerHeight;

ctx.fillStyle = "#ccc";
TweenLite.defaultEase = Power1.easeInOut;

//since we're not displaying the SVG, it's a waste of CPU cycles to update it so we'll skip updating the target by default (meaning MorphSVGPlugin won't update the "d" attribute; it'll just call the render method and feed the RawPath to it so that we can draw it to the canvas). We could set this on a per-animation basis by passing updateTarget:false in the morphSVG object, like morphSVG:{shape:"#id", render:draw, updateTarget:false}
MorphSVGPlugin.defaultUpdateTarget = false;

var tl = new TimelineMax({delay:0.5, repeat:-1, yoyo:true, repeatDelay:0.5});
tl.to("#hippo", 2, {morphSVG:{shape:"#circle", render:draw}})
  .to("#circle", 2, {morphSVG:{shape:"#elephant", render:draw}}, "+=0.5")
  .to("#elephant", 2, {morphSVG:{shape:"#star", render:draw}}, "+=0.5");

/*
The render function receives two parameters:

1) A RawPath (described below)
2) The target element of the tween

A RawPath is essentially an array containing an array for each contiguous 
segment with alternating x, y, x, y cubic bezier data. It's like an SVG <path> 
where there's one segment (array) for each "M" command; that segment (array) 
contains all of the cubic bezier coordinates in alternating x/y format 
(just like SVG path data) in raw numeric form which is nice because that way
you don't have to parse a long string and convert things. For example, this 
SVG <path> has two separate segments because there are two "M" commands:

<path d="M0,0 C10,20,15,30,5,18 M0,100 C50,120,80,110,100,100" />

So the resulting RawPath would be:
[
  [0, 0, 10, 20, 15, 30, 5, 18],
  [0, 100, 50, 120, 80, 110, 100, 100]
]

For simplicity, the example above only has one cubic bezier in each
segment, but there could be an unlimited quantity inside each segment.
No matter what path commands are in the original <path> data string 
(cubic, quadratic, arc, lines, whatever), the resulting RawPath 
will ALWAYS be cubic beziers.

Inside the function, "this" refers to the tween instance. 
*/
function draw(rawPath, target) {  
  var l, segment, j, i;
  ctx.clearRect(0, 0, vw, vh);
  ctx.beginPath();
  for (j = 0; j < rawPath.length; j++) {
    segment = rawPath[j];
    l = segment.length;
    ctx.moveTo(segment[0], segment[1]);
    for (i = 2; i < l; i+=6) {
      ctx.bezierCurveTo(segment[i], segment[i+1], segment[i+2], segment[i+3], segment[i+4], segment[i+5]);
    }
    if (segment.closed) {
      ctx.closePath();
    }
  }
  ctx.fill("evenodd");
}


/* 
The animation code could be even shorter by leveraging MorphSVGPlugin.defaultRender like so: 

//set a default render function
MorphSVGPlugin.defaultRender = draw;

//now all of our morphSVG animations will render to draw() as well.
var tl = new TimelineMax({delay:0.5, repeat:-1, yoyo:true});
tl.to("#hippo", 2, {morphSVG:"#circle"})
  .to("#circle", 2, {morphSVG:"#elephant"})
  .to("#elephant", 2, {morphSVG:"#star"});
  
*/
              
            
!
999px

Console