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

              
                <!-- stroke-dasharray="25.382" stroke-dashoffset="12.691" -->
	<svg width="256" height="320" viewBox="0 0 64 80">
		<defs>
			<!-- for better example: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/clipPath  -->
			<clipPath id="letter-s">
				<path transform="translate(16, 0)" d="M56,0 L24,0 C24,0 0,0 0,24 C0,48 24,48 24,48 L32,48 C32,48 40,48 40,56 C40,64 32,64 32,64 L0,64 L0,80 L32,80 C32,80 56,80 56,56 C56,32 32,32 32,32 L24,32 C24,32 16,32 16,24 C16,16 24,16 24,16 L56,16 L56,0 Z"/>
			</clipPath>
		</defs>
		<g class="circle">
			<!-- we use negative (x, y) coords so that the center of the rect is at (0, 0) so that when we rotate it's rotated at it's center. Also, so that the center is on the path -->
      <rect x="-8" y="-8" rx="8" ry="8" width="16" height="16" style="stroke-dasharray: 49.94157791137695;stroke-dashoffset: 49.94157791137695;transform:rotate(90deg);"/>
    </g>
    <!-- add .001 to third C to fix firefox path issue -->
    <path d="M0,72 L48,72 C48,72 64,72 64,56 C64,40 48,40 48,40 L40,40 C40.001,40.001 24.001,40.001 24.001,24.001 C24.001,8.001 40.001,8.001 40.001,8.001 L64,8 " class="path" />
    <!-- <rect x="16" y="48" height="32" width="56" stroke="red" clip-path="url(#letter-s)" class="red" /> -->
    <path d="M16,80 L72,80" stroke="#00FEEF" stroke-width="0" class="stripe red" clip-path="url(#letter-s)"/>
    <path d="M16,80 L72,80" stroke="#09EBEE" stroke-width="0" class="stripe orange" clip-path="url(#letter-s)"/>
    <path d="M16,80 L72,80" stroke="#19CEEB" stroke-width="0" class="stripe yellow" clip-path="url(#letter-s)"/>
    <path d="M16,80 L72,80" stroke="#28ACEA" stroke-width="0" class="stripe green" clip-path="url(#letter-s)"/>
    <path d="M16,80 L72,80" stroke="#388EE9" stroke-width="0" class="stripe blue" clip-path="url(#letter-s)"/>
    <path d="M16,80 L72,80" stroke="#3D76E0" stroke-width="0" class="stripe purple" clip-path="url(#letter-s)"/>

    <g class="letter" id="#letter-s">
      <path d="M16,72 L16,64 L48,64 " class="first"/>
      <path d="M16,72 L16,80 L48,80 " class="first"/>
      <path d="M48,64 C48,64 56,64 56,56 C56,48 48,48 48,48 " class="second"/>
      <path d="M48,80 C48,80 72,80 72,56 C72,32 48,32 48,32 " class="second"/>
      <path d="M48,32 L40,32 " class="third"/>
      <path d="M48,48 L40,48 " class="third"/>
      <path d="M40,32 C40.001,32.001 32.001,32.001 32.001,24.001 C32,16 40,16 40,16 " class="fourth"/>
      <path d="M40,48 C40.001,48.001 16.001,48.001 16.001,24.001 C16,0 40,0 40,0 " class="fourth"/>
      <path d="M40,0 L72,0 L72,8 " class="fifth"/>
      <path d="M40,16 L72,16 L72,8 " class="fifth"/>
    </g>
</svg>

<div style="margin-top: 50px;">
<button id="restart"><svg height="16px" width="16px" aria-hidden="true" data-prefix="fas" data-icon="sync" class="svg-inline--fa fa-sync fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M440.935 12.574l3.966 82.766C399.416 41.904 331.674 8 256 8 134.813 8 33.933 94.924 12.296 209.824 10.908 217.193 16.604 224 24.103 224h49.084c5.57 0 10.377-3.842 11.676-9.259C103.407 137.408 172.931 80 256 80c60.893 0 114.512 30.856 146.104 77.801l-101.53-4.865c-6.845-.328-12.574 5.133-12.574 11.986v47.411c0 6.627 5.373 12 12 12h200.333c6.627 0 12-5.373 12-12V12c0-6.627-5.373-12-12-12h-47.411c-6.853 0-12.315 5.729-11.987 12.574zM256 432c-60.895 0-114.517-30.858-146.109-77.805l101.868 4.871c6.845.327 12.573-5.134 12.573-11.986v-47.412c0-6.627-5.373-12-12-12H12c-6.627 0-12 5.373-12 12V500c0 6.627 5.373 12 12 12h47.385c6.863 0 12.328-5.745 11.985-12.599l-4.129-82.575C112.725 470.166 180.405 504 256 504c121.187 0 222.067-86.924 243.704-201.824 1.388-7.369-4.308-14.176-11.807-14.176h-49.084c-5.57 0-10.377 3.842-11.676 9.259C408.593 374.592 339.069 432 256 432z"></path></svg></button>
  <div>
              
            
!

CSS

              
                body {
  padding: 1rem;
  background-color: black;
}
svg {
  overflow: visible !important;
  fill: none;
}
.letter path {
  fill: none;
  stroke: #FFF;
}
.circle rect {
  stroke: #fff;
}
              
            
!

JS

              
                var speed = 1;
var path = anime.path('.path');
var restart = document.querySelector('#restart');
var timeline = anime.timeline({});
var pathTimeline = anime.timeline({});

pathTimeline
  .add({
  targets: '.circle rect',
  strokeDashoffset: 49.94157791137695,
  strokeDasharray: 24.97078895568848,
  rotate: '0deg',
  duration: 77 * speed,
  easing: 'linear'
})
  .add({
  targets: '.circle',
  translateX: path('x'),
  translateY: path('y'),
  rotate: path('angle'),
  duration: 2000 * speed,
  // loop: true,
  easing: 'linear',
  offset: 0
})
  .add({
  targets: '.circle rect',
  rx: 0,
  ry: 0,
  strokeDashoffset: 56,
  strokeDasharray: 32,
  easing: 'linear',
  duration: 50 * speed,
});

timeline
  .add({
  targets: '.letter .first',
  strokeDashoffset: [anime.setDashoffset, 0],
  easing: 'linear',
  duration: 450 * speed,
  delay: 77 * speed,
})
  .add({
  targets: '.letter .second',
  strokeDashoffset: [anime.setDashoffset, 0],
  easing: 'linear',
  duration: 556 * speed,
  offset: '-=0'
})
  .add({
  targets: '.letter .third',
  strokeDashoffset: [anime.setDashoffset, 0],
  easing: 'linear',
  duration: 91 * speed,
  offset: '-=0'
})
  .add({
  targets: '.letter .fourth',
  strokeDashoffset: [anime.setDashoffset, 0],
  easing: 'linear',
  duration: 556 * speed,
  offset: '-=0'
})
  .add({
  targets: '.letter .fifth',
  strokeDashoffset: [anime.setDashoffset, 0],
  easing: 'linear',
  duration: 450 * speed,
  offset: '-=0'
})
  .add({
  targets: '.stripe',
  strokeWidth: function(el, i, l) {
    var width = 80/6;
    return (width * l) - (i  * width);
  },
  delay: function(el, i, l) {
    return 200 * i;
  },
  elasticity: 800
});

restart.addEventListener('click', function() {
				timeline.restart();
				pathTimeline.restart();
});

              
            
!
999px

Console