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

Auto Save

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 viewBox="0 0 1200 870" preserveAspectRatio="xMinYMin meet" style="enable-background:new 0 0 1200 870;">  
  <defs>
    <path id="shape" d="M 331 162 C 359.8 129.7 399.1 107.2 441.3 97.6 C 483.5 88.1 528.4 91.5 569 106.5 C 609.6 121.4 645.8 147.8 673.1 181.4 C 700.5 214.9 719 255.4 727.4 297.8 C 744.2 382.7 719.1 473.6 666.4 542.2 C 613.7 610.8 535.1 657.6 451 678 C 408.1 688.4 363.4 692.3 319.6 687.1 C 275.7 681.9 232.7 667.4 196 643 C 159.2 618.6 128.8 584.1 111.3 543.5 C 93.8 503 89.7 456.4 102 414 C 110.9 383.3 128.2 355.1 151.5 333.2 C 174.7 311.3 203.8 295.6 234.8 288.1 C 265.9 280.7 298.9 281.3 329.6 289.9 C 360.4 298.4 389 314.8 412 337 C 449.9 373.5 472.2 426.5 468.6 479 C 466.8 505.3 458.7 531.1 444.8 553.5 C 430.9 575.8 411.2 594.6 388 607 C 355.9 624.2 317.5 628.9 282 621 C 254.9 615 229.2 601.7 209.7 581.9 C 190.2 562.1 177.2 535.7 175 508 C 173.5 488.9 177 469.6 184.7 452.1 C 192.3 434.6 204.1 418.9 218.4 406.3 C 247.2 381.1 285.8 368.5 324 368 C 365.7 367.4 406.7 380.5 443.5 400.1 C 480.3 419.7 513.3 445.7 545.2 472.6 C 577.1 499.4 608.2 527.4 642.2 551.5 C 676.2 575.6 713.5 596 754 606 C 801.2 617.6 851.9 614.4 897.6 597.6 C 943.2 580.8 983.7 550.5 1013.2 511.8 C 1042.8 473.2 1061.4 426.3 1067 378 C 1072.7 329.7 1065.5 280 1047 235 C 1026.5 185.1 992 140.9 947.8 110 C 903.7 79 849.9 61.6 796 62 C 753.9 62.3 711.8 73.5 675.8 95.1 C 639.7 116.7 609.8 148.9 592 187 C 572.6 228.5 567.9 276.6 577.8 321.4 C 587.6 366.1 611.7 407.5 645 439 C 674.9 467.2 711.4 487.4 748.3 505.3 C 785.3 523.3 823.3 539.4 858.3 561 C 893.2 582.7 925.4 610.4 945.4 646.4 C 955.3 664.4 962.1 684.2 964.1 704.7 C 966.1 725.1 963.2 746.2 955 765 C 947.2 782.8 934.7 798.4 919.6 810.6 C 904.5 822.8 886.9 831.8 868.4 837.8 C 831.5 849.7 791.7 849.8 753 846 C 648.1 835.7 545.9 796.8 462 733 C 398.4 684.6 345.4 621.9 310.9 549.9 C 276.5 477.8 260.8 396.5 269 317 C 274.8 260.7 293.3 204.2 331 162" />
  </defs>    
</svg>
              
            
!

CSS

              
                body {
  overflow: hidden;
}

svg {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
}

polyline {
  fill: none;  
  visibility: hidden;
  stroke-width: 0; 
  stroke-linecap: round;
  stroke-linejoin: round;
}


              
            
!

JS

              
                TweenLite.defaultEase = Linear.easeNone;

var colors = ["#EA4335", "#FBBC05", "#34A853", "#4285F4"];

var svgns = "http://www.w3.org/2000/svg";
var root  = document.querySelector("svg");

var time  = 6;
var lines = 100;
var step  = 1 / colors.length;
var timeStep = time * step;
var timeFill = time - timeStep;

var cursor = { x: 0, y: 0 };
var values = MorphSVGPlugin.pathDataToBezier("#shape");
var bezier = TweenLite.to(cursor, time, { 
  bezier: { values, type: "cubic" }, 
  puased: true 
}).progress(1).progress(0);

var startX = cursor.x;
var startY = cursor.y;

var tl = colors.reduce(bezierPath, new TimelineMax({ repeat: -1, repeatDelay: 0.5 }));

function bezierPath(timeline, stroke, index) {
    
  var dash = { head: 0, tail: 0 };
  var path = document.createElementNS(svgns, "polyline");
  
  path.style.stroke = stroke;
  root.appendChild(path);   
  
  var tl = new TimelineMax({ onUpdate, onUpdateParams: [path, dash] })
    .set(path, { autoAlpha: 1, strokeWidth: 30 })  
    .to(dash, timeStep, { head: step })
    .to(dash, timeStep, { head: step * 2, tail: step })
    .to(dash, timeFill, { head: 1, tail: 1 - step })
    .to(dash, timeStep, { tail: 1 })
    .set(path, { autoAlpha: 0, strokeWdith: 0 });
    
  return timeline.add(tl, timeStep * index);
}

function onUpdate(path, dash) {
  
  var points = [];
    
  var i = lines + 1;
  var start = dash.head;
  var delta = dash.tail - start;
  
  while (i--) {
    
    // var progress = lerp(dash.head, dash.tail, i / lines);    
    var progress = start + delta * i / lines;
    bezier.progress(progress);
    points.push(cursor.x, cursor.y);
  }
    
  path.setAttribute("points", points);
}

function lerp(min, max, amt) {
  return min + (max - min) * amt;
}












              
            
!
999px

Console