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

              
                <div class="buttons">
  <button id="run">RUN</button>
</div>

<div class="container">
  <svg id="svg-0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 170 170" class="svg inline" height="170" width="170">
  <g fill="none" stroke="#282D33" stroke-width="5">
    <path d="M154 65.6v43c0 6.3-2.6 12-6.6 16.4M102.3 124.1c-3.5-4.1-5.6-9.5-5.6-15.2V65.8M113.7 121.3c-14.3 2.6-26 9.9-32 19.8M167.5 141.1c-5.9-9.8-17.7-17.3-32-19.8"/>
    <path d="M152.5 75.6c5.6 0 10.1 4.5 10.1 10.1s-4.5 10.1-10.1 10.1M98.3 95.8c-5.6 0-10.1-4.5-10.1-10.1s4.5-10.1 10.1-10.1M135.2 112.4v10.2c0 5.9-4.8 10.5-10.5 10.5-5.9 0-10.5-4.8-10.5-10.5v-10.2"/>
    <path d="M154 90.1c0 13.1-10.5 23.6-23.6 23.6h-9.9c-13.1 0-23.6-10.5-23.6-23.6v-43c0-13.1 10.5-23.6 23.6-23.6h10c13.1 0 23.6 10.5 23.6 23.6l-.1 43z"/>
    <path d="M130.4 23.4h-9.9c-13.1 0-23.6 10.5-23.6 23.6v28.2c11.9-1 23-12 28.6-27.8 5.6 15.8 16.8 26.7 28.6 27.8V47.1c-.1-13.2-10.6-23.7-23.7-23.7zM115.3 90.6V95c0 3.5 2.8 6.2 6.2 6.2h4.4c3.5 0 6.2-2.8 6.2-6.2v-4.4h-16.8z"/>
  </g>
  <g fill="none" stroke="#282D33" stroke-width="5">
    <path d="M2.5 146.6v-14.7c0-6.5 5.9-11.7 13.2-11.7h58.2M74.5 59.3v23.1c0 16.4-13.2 29.6-29.6 29.6-16.4 0-29.6-13.2-29.6-29.6V58.9"/>
    <path d="M34.4 27.6c-4.8 0-9 2.4-11.4 6.2h-7.7c-5.9 0-10.7 4.8-10.7 10.7v38.6h10.5V60c0-4.1 3.3-7.5 7.5-7.5h48c7.5 0 13.7-6.2 13.7-13.7V27.5c-.2.1-49.9.1-49.9.1zM52.8 121.8v13.8M42.8 121.8v13.8"/>
  </g>
  <path fill="none" stroke="#282D33" stroke-width="5" d="M34.3 85.3c.3 7.1 5.4 12.6 11.6 12.6s11.3-5.6 11.6-12.6H34.3z"/>
<!--   <rect width="100%" height="100%" fill="rgba(255,255,255,0"/> -->
</svg>
<!-- <svg id="svg-0" viewBox="0 0 170 170" class="svg inline" role="img" ref="1" height="170" width="170" x="0" y="0">
<metadata>
	<sfw xmlns="http://ns.adobe.com/SaveForWeb/1.0/">
		<slices></slices>
		<sliceSourceBounds width="170" height="101.6" y="305.2" x="554" bottomLeftOrigin="true"></sliceSourceBounds>
	</sfw>
</metadata>
<g id="Icons">
	<g>
		<line fill="none" stroke="#282D33" stroke-width="5" x1="139.5" y1="48.5" x2="30.7" y2="48.5"></line>
		<line fill="none" stroke="#282D33" stroke-width="5" x1="30.7" y1="109.4" x2="139.5" y2="109.4"></line>
		<path fill="none" stroke="#282D33" stroke-width="5" d="M2.5,121.1v7.9c0,0,5.7,4.3,9.9,4.3h52.5h40.2h52.5c4.2,0,9.9-4.3,9.9-4.3    v-7.9H2.5z"></path>
		<path fill="none" stroke="#282D33" stroke-width="5" d="M46,88.3h13.6h51.2h13.6c3.1,5.9,9.3,9.9,16.3,9.9    c7.4,0,13.9-4.5,16.8-10.8h-15.7l-4.5-7.9l4.5-7.9h15.7c-2.9-6.3-9.4-10.8-16.8-10.8c-7.1,0-13.2,4-16.3,9.9h-13.6H59.6H46    c-3.1-5.9-9.3-9.9-16.3-9.9c-7.4,0-13.9,4.5-16.8,10.8h15.7l4.5,7.9l-4.4,7.9H13c2.9,6.3,9.4,10.8,16.8,10.8    C36.8,98.1,42.9,94.1,46,88.3z"></path>
		<path fill="none" stroke="#282D33" stroke-width="5" d="M148.8,55.1V41c0-2.5-2-4.3-4.3-4.3H26c-2.5,0-4.3,2-4.3,4.3v14.2"></path>
		<g>
			<line fill="none" stroke="#282D33" stroke-width="5" x1="148.8" y1="121.6" x2="148.8" y2="106.3"></line>
			<line fill="none" stroke="#282D33" stroke-width="5" x1="21.5" y1="106.3" x2="21.5" y2="121.6"></line>
		</g>
	</g>
</g>
<rect x="0" y="0" width="100%" height="100%" fill="rgba(255,255,255,0"></rect></svg> -->

</div>

              
            
!

CSS

              
                html, body {
  height: 100%;
  background: #000000;
}

body {
  overflow: hidden;
}

.buttons {
  text-align: center;
  width: 100%;
}

button {
  font-size: 16px;
  padding: 5px 10px;
  display: inline-block;
}

button.hidden {
  visibility: hidden;
}

.container {
  width: 200px;
  margin: 0 auto;
  padding-top: 100px;
}

svg {
  width: 100%;
  height: 100%;
/*   background: rgb(0,0,17); */
}

svg path {
  fill: none;
}

              
            
!

JS

              
                var root, selectorArr, linedIn, TL, colors, strokeWidth = 5,
original = document.querySelector('#svg-0').innerHTML;

function init() {  
  MorphSVGPlugin.convertToPath("circle, rect, ellipse, line, polygon, polyline");
  TweenLite.defaultEase = Linear.easeNone;
  root = document.querySelector('#svg-0');
  selectorsArr = document.querySelectorAll("path");

  TL = new TimelineMax();
  colors = [
    [255, 0, 0],
    [255, 128, 0],
    [237, 142, 142],
    [232, 187, 142]
  ];

  TweenMax.set(selectorsArr, {visibility: 'hidden'});
}

// DRAW IN FIRST
function drawIn() {
  var rbg = toRgb(colors);
  TL.staggerFromTo( selectorsArr, 0.3, 
  { drawSVG: '0' }, { drawSVG: '0 100%', 
    stroke: function(){
      return rbg[Math.floor(Math.random() * rbg.length)];
    },
    visibility: 'visible'
  }, 0.3, 0, pertyColors);
}

/************************************************************* /\\
 * BLAKE'S MULTI-COLOR LINE ANIMATOR FUNCTION
 ************************************************************** */
function pertyColors() {
  // snag the svg before paths get duped
  linedIn = $('#svg-0').html();
  
  [].forEach.call(selectorsArr, function(sel) {
    var total = 4, space = 3, length = sel.getTotalLength(), offset = length / total;
    colors.sort(function() { return 0.5 - Math.random() });
    colors.push(colors[0].slice(0));
    var gradient = [];

    for(var i = 0; i < total; i++) {
      var amt = i / (total - 1);
      var rgb = lerpColors(colors, amt).map(color => Math.round(color));
      gradient.push(`rgb(${rgb})`);
    }

    TweenLite.set(sel, { strokeDasharray: `${offset + space},${length - offset - space}`, strokeWidth: strokeWidth, strokeLinejoin: "round" });
    
    var tl = gradient.reduce((tl, stroke, i) => {
      var clone = sel.cloneNode(true);
      root.appendChild(clone);
      TweenLite.set(clone, { stroke, strokeDashoffset: -i * offset });
      return tl.to(clone, 2, { strokeDashoffset: `+=${length}` }, 0);
    }, new TimelineMax({repeat: 1}));
  });
  // Wrapping it with a fake fromTo in order to limit animation time and move on to the next thing
  tw = TweenMax.to("#svg-0", -1, {x:0, y:0});
  TL.add(tw,"+=0");
}

function drawOut() {
  // document.querySelector('#svg-0').innerHTML = linedIn;
  var selectorsArr = document.querySelectorAll("path");
  TL.staggerTo(selectorsArr, 0.3, { drawSVG: '0', onCompleteAll: reset}, 0.3);
}

function reset() {
  document.querySelector('#svg-0').innerHTML = original;
  init();
}

$('button#run').on("click", function(){
  TL.seek(0);
  drawIn();
});

init();
/************************************************************* /\\
 * COLOR SETTING STUFF
 ************************************************************** */
function lerp(start, end, amt) { 
  return start + (end - start) * amt; 
}

function lerpColor(start, end, amt) { 
  var rgb = [];
  for(var i = 0; i < start.length; i++) {
    rgb[i] = lerp(start[i], end[i], amt);
  } 
  return rgb;
}

function lerpColors(colors, amt) {
  if (amt >= 1) return colors[colors.length - 1];
  amt *= (colors.length - 1);
  var i = amt >> 0;
  return lerpColor(colors[i], colors[i + 1], amt - i);
}

function toRgb(colorArr) {
  var colors = [];
  for ( var c=0; c<colorArr.length; c++ ) {
    var newC = `rgb(${colorArr[c]},${colorArr[c]},${colorArr[c]})`;
    colors.push(newC);
  }
  return colors;
}

              
            
!
999px

Console