HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<svg id="demo" xmlns="http://www.w3.org/2000/svg" width="1500" height="750" viewBox="0 0 1500 750">
<title>Handwriting With DrawSVG Demo</title>
<g class="theWords" stroke-linejoin="round">
<g id="background">
<rect id="bgBase" width="1500" height="750" rx="10" ry="10"/>
<rect id="bg" x="10" y="10" width="1480" height="730" rx="8" ry="8" fill="#2b2728"/>
</g>
<g id="handwriting" >
<path id="hPipe" d="M236.07,153.69c-3.55-1.68-8,.46-10.13,3.73s-2.66,7.34-3.09,11.24l-8.29,75c-4,36-7.93,72.65-1.11,108.22" fill="none" stroke="#fff" stroke-linecap="round" stroke-miterlimit="10" stroke-width="14"/>
<path id="hBody" d="M364.08,140.94c-10.74,20.86-12.65,45-14.36,68.4-2.67,36.51-5.33,73-6.58,109.62-.37,10.82-1.14,22.88-9.07,30.26-5.67,5.28-14,6.9-21.69,6s-14.9-4.1-21.9-7.41c-14.49-6.85-28.74-14.53-41-24.84s-22.54-23.47-27.37-38.75c-1.08-3.43-1.88-7.19-.66-10.57,2.15-6,9.3-8.14,15.5-9.43a685.2,685.2,0,0,1,141.5-14.29" fill="none" stroke="#fff" stroke-linecap="round" stroke-miterlimit="10" stroke-width="10"/>
<path id="tCross" d="M936.82,232.3l126.7.62" fill="none" stroke="#fff" stroke-linecap="round" stroke-miterlimit="10" stroke-width="10"/>
<path id="mainPath" d="M430.67,293.63c-.14-17.07-11.85-15.24-19.57-12.45-9.24,3.33-15,11.36-20.07,19.79-5.88,9.83-6.93,27.7-4.74,36.25,1.47,5.74,2,14.62,18.85,11.58,12.56-2.26,24.65-29.75,26.79-40.5.28-1.41-2.19-2.77-3.23-.29-4,9.64-2.92,37.15,12.84,39.65,16.59,2.63,24.24-7.82,32.52-16.85,7.68-8.38,15.36-25.09,19.87-35.55a3.26,3.26,0,0,1,1.41-1.35,2,2,0,0,1,3,1.65l2.31,45.08c1.81,5.21,4.9,5.71,7.06,4,9.62-7.77,22.94-41.78,29-55.92.88-2,5.33-.89,5.25,1.33-.23,6.13-5.25,26.5-4.85,36.35.43,10.45,10.62,19.45,21,21,16.73,2.52,29-14.82,36.71-29.9,7.1-13.93,17.7-34.07,32.52-35.25,2.54-.2,3.65,1,.61,1.86-12.76,3.64-22.57,18.79-28.57,30.47-4.18,8.14-10.46,33.39,12.41,36.22,13,1.61,23.54-14.43,29.6-26C662.59,284.09,680,233.82,681.5,188a4,4,0,0,0-3.27-4c-6.59-1.16-12.72,5.94-17.07,12.35-4.52,6.66-8.36,16.89-10.19,24.72-6.47,27.59-13.52,54.09-12,82.39,1,18.52,7.07,40.91,25.1,45.26,11.57,2.8,24.74-3.09,31.13-13.13,6.09-9.55,16.65-34.29,19.66-44.43.78-2.62,0-3-1.71-.9-9.69,12.2-8.24,57.4,7.87,59.84,15,2.26,35.28-32.75,32.41-48.23-1.8-9.68-3.74-7.47-4.54,2.34s1.67,40.69,11.55,42.88c13,2.86,21.49-10.74,26.08-22.68,4.2-10.94,8.74-38.81,6.93-45.29-.69-2.46-2.11-3.44-3.47-1.28-7.07,11.29-7.29,32-.38,42.1a9.86,9.86,0,0,0,5.21,3.81c13.14,4.12,24.61,2.69,34.39-9.18,9.63-11.7,22.93-48.6,14.49-44.34-5.17,2.79,5.18,34,21.65,15.61,1.47-1.64,8.54,3.8,6.9,6.73-14.56,26.06-13.79,49.36,5.78,54.18,20,4.91,50.24-28.82,49.09-49.15a1,1,0,0,0-1.92-.36c-6.07,13.62-.64,50.56,14.69,53,16.39,2.57,32.33-15.23,40.63-29.59s10.35-30.64,12.42-47.1c1.6-12.72,3.53-39.19,8.39-54.48,2.68-8.45,4.48-8.08,3.83.76-3,41.73-11.71,63.65-13.69,93.66-.81,12.26,0,12.19,3.45,18.55,9.75,17.77,27.08,13.16,38,5.44,11.2-7.89,24.9-25.72,24.84-38.85,0-.52-1.06-2.94-3-1.86-11.19,6.25-4.39,42,8.06,50.8,12,8.44,29-1.39,37.94-13.06A102.11,102.11,0,0,0,1111,319.25c3.9-7.18,13.18-29.34,18.25-24.37,5.78,5.66,2,29.55.83,41.08-.42,4.13-.42,6.42,3.58,7.79,5.4,1.85,13.12-6.36,15.25-12.21,2.62-7.2,4.9-12.58,7-19.33,2.21-7,9.68-23,11.65-23.83.9-.4,3-.19,3.4.83,4,10.37-8.26,27.83.49,47.91,2.52,5.79,5,11.34,19.75,10.5,10.29-.58,16.59-7.64,21.53-11.83,9.75-8.29,13.91-21.23,21.66-31.42,5.09-6.69,13.58-23.94,23.6-23.86,18.89.16,15.56,15.64,12.41,11-7.56-11.14-16.88-8.77-31.05,10.95-7.35,10.23-14.42,33-7.13,43.27,9.09,12.83,24.2,2.83,32.6-10.46,3.53-5.59,11.09-27,12.36-33.42,2.72-13.69,15.12-24.92,8.61-12.57-23,43.61-9.36,98.77-12,148-.66,12.51,1.75,19.5-10.58,46.33-5.28,11.49-18.3,22.54-28.53,17.4-10.67-5.37-6.58-29.85-4.77-41.11,6.29-39,44.46-101,60.67-99.79" fill="none" stroke="#fff" stroke-linecap="round" stroke-miterlimit="10" stroke-width="10"/>
<ellipse id="dot2" cx="926.5" cy="268.98" rx="9.68" ry="8.1" transform="translate(538.8 1152.4) rotate(-82.49)" fill="#fff"/>
<ellipse id="dot1" cx="1056.39" cy="268.98" rx="9.68" ry="8.1" transform="translate(651.72 1281.18) rotate(-82.49)" fill="#fff"/>
</g>
<g id="is">
<ellipse id="dot3" cx="475.71" cy="403.96" rx="9.68" ry="8.1" transform="translate(13.06 822.82) rotate(-82.49)" fill="#fff"/>
<path id="isPath" d="M474.84,432c-1.93,6.86-2.64,14-3.19,21.1s.38,14.5,3.9,20.7,9.89,11,17,11.49c5.95.4,11.8-2.21,16.38-6s7.65-9.06,11.34-13.74c14.7-18.62,24.95-45.15,32.25-66.63a3.24,3.24,0,0,1,1.69-1.95c4.45-2,1.7,14.29,3.73,19.79,2.36,6.43,7.19,13.94,8.41,20.68s1.13,13.89-1.52,20.2-10.93,14.15-18.67,14.17c-2.78,0-6.33-1.83-10.75-8.05-1.22-1.71-3.57,1.63-2.19,3.21,5.93,6.77,9.31,15.94,27.43,17.63,20.89,2,27-3.29,37.06-12.16s16.62-21.25,20-34.24" fill="none" stroke="#fff" stroke-linecap="round" stroke-miterlimit="10" stroke-width="10"/>
</g>
<g id="easy">
<ellipse id="dot4" cx="1022.69" cy="485.51" rx="9.68" ry="8.1" transform="translate(407.74 1436.01) rotate(-82.49)" fill="#fff"/>
<path id="easyPath" d="M706,468.5l16.63-30.31c2.57-4.68,5.19-9.54,5.59-14.85s-1.79-13-6.77-15c-4.61-1.77-10.26,2.23-13.62,5.85s-5.13,8.39-6.77,13c-3,8.5-5.91,17.22-6.09,26.23s2.3,19.11,9.67,24.3c14.3,10.07,22.07,12.2,42.18-4.68,11.95-10,17.78-26.68,25.25-40.37,3.3-6.06,7-11.63,12.5-15.75a17.35,17.35,0,0,1,18.13-2.12c4.54,2,7.6,8.81,8.08,13,.26,2.27-.38,2.44-1.24.33-2.18-5.34-5-13.24-14.22-13.12-7.58.1-13.91,6.87-18.37,13a63.26,63.26,0,0,0-9.61,19.46c-3,9.87-4.86,24.65,2.36,32,10.88,11.13,18.46,3.12,25.63-5.25,6-7.07,11.31-23.58,13-33.12.21-1.19,4.22,0,3.78,1.16-3,7.67-6.6,21.23-3,28.5,7.43,14.84,18,14.65,25.43,11.18s15.06-8.81,19.78-15.6,7.14-15.07,10-22.82c4.93-13.14,11.65-30.26,17-43.84a2.41,2.41,0,0,1,4.58.32c2.25,9.18,1.87,21.66,6.58,30.19,5.27,9.51,5.81,23.11-.33,32.08-4.41,6.45-15.92,13.67-24.67,2-1-1.3-5.16,3.7-1.92,7,19,19.33,36.41,18.61,50.58,9.17,16.34-10.89,28.88-32.53,32.83-49.54,1.33-5.72,3-5.79,2,0-1.15,6.88-3.69,20.66-5.07,27.06-2.55,11.79.62,25.55,11.82,24.88,4-.24,7.55-1.35,10.12-3.84,10.2-9.93,10.48-14,12.55-18.62l15.69-38.84c1.81-4.51,6.22-2,3.2,2.33-9.8,14-14.43,110.52-22.54,147.65a85.79,85.79,0,0,1-10.08,25.25c-6,10.5-11.55,10.85-19.33,9.42-7-1.28-11.42-10.59-13.33-17.42s-1.35-13.82.5-20.67C944.5,531.63,966,488,995.88,492.38" fill="none" stroke="#fff" stroke-linecap="round" stroke-miterlimit="10" stroke-width="10"/>
</g>
</g>
<g id="hand">
<rect id="groupSizer" width="140" height="160"/>
<path d="M55.25,55.9,48.63,82.66s-27.58,40.19-26.86,16C23.31,47.27,55.25,55.9,55.25,55.9Z" fill="#f49f58"/>
<path d="M77.45,30.06C75.95,29.74,27.15,45,24.08,46.12S13.72,48,11.42,53.79s0,16.5,0,21.1-1.15,33.38-.77,37.6c.24,2.7,3.45,5.37,6.52,5.75s8.06-4.6,9.21-7.67,6.52-40.67,7.29-43.35,13-1.15,15.73-1.15,26.47,23.4,26.47,26.86-14.19,19.57-16.11,19.57-29.63,6.77-31.46,8.06c-3.84,2.69-6.93,9.81-5.75,16.88.77,4.6,6.14,6.14,10.36,5.76,3.62-.33,24.17-1.53,30.69-1.92,4.28-.25,12.66-3.84,15-5.37S97,121.7,98.12,119.78s15.08-12.56,17.26-16.69c3.45-6.52,14.39-48.34,13.24-50.07C123.39,45.17,83.76,31.37,77.45,30.06Z" fill="#ffc585"/>
<path d="M119.82,46.59c-7.44-4-18-8.3-26.85-11.51h0C81.87,48.19,69.38,60,56.92,71.77h0c7.89,7.16,19,18.8,19,21.15,0,1.58-3,5.82-6.39,9.95h0c1.15,0,8.42,8.43,21.74-4.39C111.74,78.73,119,66.42,120.74,56.26A17,17,0,0,0,119.82,46.59Z" fill="#ffc585" opacity="0.4" style="mix-blend-mode: multiply"/>
<path d="M14.1,70.29c-2.3,7.29-9.8,45.47-10,49.11-.21,4.32,1.83,7.15,5.75,6.91,3.39-.21,8.58-2.94,10.36-6.14,3.34-6,4.19-5.22,11.13-50.26Z" fill="#ffc585"/>
<path d="M14.1,70.29c-2.3,7.29-9.8,45.47-10,49.11-.21,4.32,1.83,7.15,5.75,6.91,3.39-.21,8.58-2.94,10.36-6.14,3.34-6,4.19-5.22,11.13-50.26Z" fill="#ffc585" opacity="0.4" style="mix-blend-mode: multiply"/>
<g>
<path d="M115.22,36.89s-4.3,37.94-5.1,39.36S83.83,106.38,81.9,107.18,69.43,109.49,71.37,105s7.33-2.93,8.17-3.66S101.42,75.61,102,74.43s.74-30,.74-30Z" fill="#363f4f"/>
<path d="M113.07,39.08s-3.87,36-4.66,37.41S83.11,106.2,81.18,107s-11.75,2.49-9.81-2,7.33-2.93,8.17-3.66S101.42,75.61,102,74.43s.74-30,.74-30Z" fill="#4b5668"/>
<path d="M111.25,55.36c1-8.48,1.81-16.28,1.81-16.28l-10.31,5.4s-.08,15.28-.35,24C103.3,67.19,108.68,59.83,111.25,55.36Z" fill="#4b5668" opacity="0.4" style="mix-blend-mode: multiply"/>
<path d="M71.55,107.11c2.19-3.36,7.43-5.35,7.69-5.61-1.41.38-6.08-.56-7.86,3.53A1.73,1.73,0,0,0,71.55,107.11Z" fill="#4b5668" opacity="0.4" style="mix-blend-mode: multiply"/>
<path d="M33.23,86.72c10.08,3.3,24,15.06,29.31,25.8L58,117.38c-10.6-4-25.41-17.87-28-25.83Z" fill="#edbd15"/>
<path d="M46.16,94c-2.09,3-4.54,5.8-6.79,8.77-.24.32-.47.65-.7,1,5.75,5.83,13.22,11.38,19.3,13.65l4.57-4.85C59.32,106,52.93,99.13,46.16,94Z" fill="#edbd15" style="mix-blend-mode: multiply"/>
<path d="M3.79,149.09s-3.57,7.55-2.42,8.58c1.52,1.36,7.71-4.53,7.71-4.53Z" fill="#c6d0d5"/>
<path d="M7.95,150.39c-1.11,2.4-3.21,5.47-5.9,6.3a3.13,3.13,0,0,1-.73.13.78.78,0,0,0,.21.51c1.52,1.36,7.71-4.53,7.71-4.53Z" fill="#c7d1d6" style="mix-blend-mode: multiply"/>
<path d="M1.95,149.82c3.16-8.14,17.61-40.14,31.5-61.3,8.37-12.75,53.86-84,78.16-64.8,21.59,17-31.06,69.86-52.81,90.88C42,130.87,11.55,153.39,9.34,154.72S1.34,151.39,1.95,149.82Z" fill="#4b5668"/>
<path d="M49,113.63c-6.42,6.38-20.09,20-29.15,28.48C11,150.42,6.2,152.81,4.59,153.36c1.65,1.19,3.64,2,4.75,1.36,2.22-1.33,32.63-23.85,49.45-40.11C78,96.07,121.16,52.8,116.31,31.15c0,2.37-7.76,3.86-12,13.2C95.55,63.76,63.76,99,49,113.63Z" fill="#4b5668" opacity="0.4" style="mix-blend-mode: multiply"/>
<path d="M92.86,47.91c7.9,6.12,17.67,6.77,19.08,3.07,5.75-11.47,7-21.45-.34-27.26-8-6.33-18.36-2.79-28.91,5.24C80.46,32.85,84.33,41.31,92.86,47.91Z" fill="#69778b"/>
<path d="M83.79,28.14C94,20.69,103.86,17.61,111.6,23.72c7.17,5.66,6.15,15.26.79,26.34C106.53,58.36,80.56,40.72,83.79,28.14Z" fill="#edbd15"/>
<path d="M116.31,31.11c-.65,10.45-11.22,20.6-22,15.52,6.91,5.15,15.12,7.66,18.12,3.43C115.86,42.91,117.5,36.37,116.31,31.11Z" fill="#edbd15" style="mix-blend-mode: multiply"/>
<path d="M10.5,130.62c-4.17,8.76-7.28,15.93-8.55,19.21-.61,1.56,5.17,6.22,7.39,4.9,1-.59,7.45-5.31,15.83-11.79C20.75,141.85,11.74,135.18,10.5,130.62Z" fill="#edbd15"/>
<path d="M10.5,130.62c-1.89,4.89,10,12.92,14.67,12.31C20.75,141.85,11.74,135.18,10.5,130.62Z" fill="#feee28"/>
<path d="M2.51,151.41a8,8,0,0,0,.9,1c2.45-3.69,7.82-11.23,11.22-16a19.94,19.94,0,0,1-3-3.41C8.87,137.68,5,146,2.51,151.41Z" fill="#edbd15" style="mix-blend-mode: screen"/>
<path d="M20.4,140.73c-4.19,5-9,9.31-13.71,13.83a3.09,3.09,0,0,0,2.64.16c1-.59,7.45-5.31,15.83-11.79A18.38,18.38,0,0,1,20.4,140.73Z" fill="#edbd15" style="mix-blend-mode: multiply"/>
<path d="M33.23,86.72c4.3,8.5,19.27,22.52,29.31,25.8L58,117.38c-10.6-4-25.41-17.87-28-25.83Z" fill="#feee28"/>
<path d="M33.23,86.72c3.3,10,19.4,24.28,29.31,25.8L58,117.38c-10.6-4-25.41-17.87-28-25.83Z" fill="#edbd15"/>
<path d="M53.09,107.47a38.21,38.21,0,0,0,9.45,5.06L58,117.38a43,43,0,0,1-9.29-5.15C50.14,110.87,51.15,109.6,53.09,107.47Z" fill="#edbd15" style="mix-blend-mode: multiply"/>
<path d="M39,94.81c-.92-1-1.78-2.09-2.55-3.1-1.26,1.68-2.45,3.41-3.59,5.18.6.86,1.28,1.73,2,2.62A61.6,61.6,0,0,1,39,94.81Z" fill="#edbd15" style="mix-blend-mode: screen"/>
<path d="M3.45,153c1,.55-1.26,3.33-1.42,2.73S2.63,152.54,3.45,153Z" fill="#c7d1d6" opacity="0.7" style="mix-blend-mode: screen"/>
<path d="M107.61,75.33c.49-1.63-25.92,28.23-25.4,28.92S106.8,78,107.61,75.33Z" fill="#4b5668" opacity="0.7" style="mix-blend-mode: screen"/>
<path d="M101.93,22c-3.44-.3-9,3-8.18,4.61,2.2,4.21,12.06,2,12.88,0C107.76,23.75,103.74,22.19,101.93,22Z" fill="#edbd15" opacity="0.4" style="mix-blend-mode: screen"/>
<path d="M81,41.38c-5.59.22-35.49,37.16-38.3,46.24,3.74-1.84,11.19-13.24,18.86-22.54C70.83,53.89,80.15,44.46,81,41.38Z" fill="#4b5668" opacity="0.4" style="mix-blend-mode: screen"/>
<path d="M32.75,100.8c-3.63,2.63-15.13,19.8-17.94,28.88C18.78,125.16,31.85,103.88,32.75,100.8Z" fill="#4b5668" opacity="0.4" style="mix-blend-mode: screen"/>
</g>
<path d="M43.35,65.72C43.74,64.29,71.25,36,73.6,31.06c-8.52,2.7-47.07,14.14-49.52,15.06C21,47.27,13.72,48,11.42,53.79s0,16.5,0,21.1-1.15,33.38-.77,37.6c.24,2.7,3.45,5.37,6.52,5.75s8.06-4.6,9.21-7.67,6.52-40.67,7.29-43.35C34.14,65.55,39,65.51,43.35,65.72Z" fill="#ffc585"/>
<path d="M69.51,111.93a10.24,10.24,0,0,1-4.45-3.18c-2.5,2.3-4.66,3.74-5.3,3.74-1.92,0-29.63,6.77-31.46,8.06-3.84,2.69-6.93,9.81-5.75,16.88.77,4.6,6.14,6.14,10.36,5.76,3.62-.33,24.17-1.53,30.69-1.92,4.28-.25,12.66-3.84,15-5.37S97,121.7,98.12,119.78C98.3,119.48,73.84,113.57,69.51,111.93Z" fill="#ffc585"/>
<path d="M27.53,124.77c2.69-2.69,15-2.3,15.35-.38s.38,10-.38,12.28-14.19,5-15.73,2.69C23.39,134.28,25.1,127.19,27.53,124.77Z" fill="#ffd5b8"/>
<path d="M19,116a81.46,81.46,0,0,0-.29-14.29c-.34-1.68-6.65-1.76-8-2.1-.15,6-.23,11.23-.08,12.84C10.89,115.19,17.27,117.77,19,116Z" fill="#ffd5b8"/>
<path d="M117,91.87c-8.53,11-35.2,38.27-45.36,42.58-9.4,4-40.57,9.5-49.11,3,.77,4.6,6.14,6.14,10.36,5.76,3.62-.33,24.17-1.53,30.69-1.92,4.28-.25,12.66-3.84,15-5.37S97,121.7,98.12,119.78s15.08-12.56,17.26-16.69c1.12-2.12,3-7.94,5.05-14.91C119.34,89.44,118,90.54,117,91.87Z" fill="#ffc585" opacity="0.4" style="mix-blend-mode: multiply"/>
<path d="M26.38,110.57c1.15-3.07,6.52-40.67,7.29-43.35.54-1.89,6.78-1.69,11.37-1.41.76,0-11.61-4.73-14-1.47-3.27,4.54-3.16,35.87-12,50.07a5.88,5.88,0,0,1-5.31,2.53,8.13,8.13,0,0,0,3.39,1.31C20.24,118.63,25.23,113.64,26.38,110.57Z" fill="#ffc585" opacity="0.4" style="mix-blend-mode: multiply"/>
</g>
</svg>
<div id="controls">
<svg id="writingControls" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="650" height="200" viewBox="0 0 650 200">
<defs>
<lineargradient id="linear-gradient" x1="519.55" y1="83.4" x2="519.55" y2="47.4" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#6e6e6e"/>
<stop offset="0.02" stop-color="#636262"/>
<stop offset="0.05" stop-color="#4e4c4d"/>
<stop offset="0.1" stop-color="#3e3b3c"/>
<stop offset="0.15" stop-color="#333031"/>
<stop offset="0.22" stop-color="#2d292a"/>
<stop offset="0.43" stop-color="#2b2728"/>
<stop offset="0.6" stop-color="#232021"/>
<stop offset="0.86" stop-color="#0f0d0e"/>
<stop offset="1"/>
</lineargradient>
<lineargradient id="linear-gradient-2" x1="562.53" y1="83.4" x2="562.53" y2="47.4" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-3" x1="605.5" y1="83.4" x2="605.5" y2="47.4" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-4" x1="519.55" y1="128.97" x2="519.55" y2="92.97" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-5" x1="562.53" y1="128.97" x2="562.53" y2="92.97" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-6" x1="605.5" y1="128.97" x2="605.5" y2="92.97" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-7" x1="519.55" y1="176.87" x2="519.55" y2="140.87" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-8" x1="562.53" y1="176.87" x2="562.53" y2="140.87" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-9" x1="605.5" y1="176.87" x2="605.5" y2="140.87" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-10" x1="237.54" y1="182.47" x2="237.54" y2="29.47" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-11" x1="82.43" y1="96.54" x2="82.43" y2="38.4" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-12" x1="82.43" y1="89.62" x2="82.43" y2="45.32" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#0f0f0f"/>
<stop offset="0.22" stop-color="#1c1d1d"/>
<stop offset="0.71" stop-color="#353636"/>
<stop offset="1" stop-color="#3e4040"/>
</lineargradient>
<lineargradient id="linear-gradient-13" x1="82.43" y1="168.54" x2="82.43" y2="110.4" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-14" x1="82.43" y1="161.62" x2="82.43" y2="117.32" xlink:href="#linear-gradient-12"/>
<lineargradient id="linear-gradient-15" x1="411.97" y1="88.85" x2="411.97" y2="61.89" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-16" x1="411.97" y1="82.72" x2="411.97" y2="68.02" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#313131"/>
<stop offset="0.72" stop-color="#1f1f1f"/>
<stop offset="0.79" stop-color="#121212"/>
<stop offset="0.9" stop-color="#050505"/>
<stop offset="1"/>
</lineargradient>
<lineargradient id="linear-gradient-17" x1="399.25" y1="86.4" x2="399.25" y2="64.34" xlink:href="#linear-gradient-12"/>
<lineargradient id="linear-gradient-18" x1="399.25" y1="83.94" x2="399.25" y2="66.79" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#292929"/>
<stop offset="0.21" stop-color="#2c2c2c"/>
<stop offset="1" stop-color="#333636"/>
</lineargradient>
<lineargradient id="linear-gradient-19" x1="411.97" y1="162.85" x2="411.97" y2="135.89" xlink:href="#linear-gradient"/>
<lineargradient id="linear-gradient-20" x1="411.97" y1="156.72" x2="411.97" y2="142.02" xlink:href="#linear-gradient-16"/>
<lineargradient id="linear-gradient-21" x1="399.25" y1="160.4" x2="399.25" y2="138.34" xlink:href="#linear-gradient-12"/>
<lineargradient id="linear-gradient-22" x1="399.25" y1="157.94" x2="399.25" y2="140.79" xlink:href="#linear-gradient-18"/>
</defs>
<title>Handwriting Controls</title>
<rect width="650" height="200" rx="10" ry="10" fill="#333"/>
<rect x="3" y="3" width="644" height="194" rx="10" ry="10" fill="#2b2728"/>
<g id="swatcheBases">
<rect x="501.55" y="47.4" width="36" height="36" rx="4" ry="4" fill="url(#linear-gradient)"/>
<rect x="544.53" y="47.4" width="36" height="36" rx="4" ry="4" fill="url(#linear-gradient-2)"/>
<rect x="587.5" y="47.4" width="36" height="36" rx="4" ry="4" fill="url(#linear-gradient-3)"/>
<rect x="501.55" y="92.97" width="36" height="36" rx="4" ry="4" fill="url(#linear-gradient-4)"/>
<rect x="544.53" y="92.97" width="36" height="36" rx="4" ry="4" fill="url(#linear-gradient-5)"/>
<rect x="587.5" y="92.97" width="36" height="36" rx="4" ry="4" fill="url(#linear-gradient-6)"/>
<rect x="501.55" y="140.87" width="36" height="36" rx="4" ry="4" fill="url(#linear-gradient-7)"/>
<rect x="544.53" y="140.87" width="36" height="36" rx="4" ry="4" fill="url(#linear-gradient-8)"/>
<rect x="587.5" y="140.87" width="36" height="36" rx="4" ry="4" fill="url(#linear-gradient-9)"/>
</g>
<g id="swatches">
<rect x="505.55" y="51.4" width="28" height="28" rx="4" ry="4" fill="#ccc"/>
<rect x="548.53" y="51.4" width="28" height="28" rx="4" ry="4" fill="#ccc"/>
<rect x="591.5" y="51.4" width="28" height="28" rx="4" ry="4" fill="#ccc"/>
<rect x="505.55" y="96.97" width="28" height="28" rx="4" ry="4" fill="#ccc"/>
<rect x="548.53" y="96.97" width="28" height="28" rx="4" ry="4" fill="#ccc"/>
<rect x="591.5" y="96.97" width="28" height="28" rx="4" ry="4" fill="#ccc"/>
<rect x="505.55" y="144.87" width="28" height="28" rx="4" ry="4" fill="#ccc"/>
<rect x="548.53" y="144.87" width="28" height="28" rx="4" ry="4" fill="#ccc"/>
<rect x="591.5" y="144.87" width="28" height="28" rx="4" ry="4" fill="#ccc"/>
</g>
<text transform="translate(508.84 34.47)" font-size="14" fill="#fff" >STROKE COLOR</text>
<circle id="knobDepth" cx="237.54" cy="105.97" r="76.5" fill="url(#linear-gradient-10)"/>
<path id="notches" d="M238.61,17v9h-2.13V17h2.13Zm44.58,12.58L278.7,37.4l-1.84-1.06,4.49-7.82,1.84,1.07Zm32.36,33.3-7.78,4.52-1.07-1.85L314.48,61l1.07,1.84ZM327,108h-9v-2.13h9V108ZM314.49,152.8l-7.78-4.52,1.06-1.85,7.78,4.52-1.06,1.85ZM159.54,151l7.78-4.52,1.07,1.85-7.78,4.52L159.54,151Zm-11.45-45.1h9V108h-9v-2.13ZM160.6,61l7.78,4.51-1.06,1.85-7.78-4.52L160.6,61Zm33.14-32.53,4.49,7.82-1.84,1.07-4.49-7.82.37-.21h0l.46-.26,1-.59Zm132.39,90.74-4.45-.59.17-1.27,4.45.59-.16,1.27ZM148.8,118l4.45-.59.16,1.27-4.45.59L148.8,118ZM151,129.55l4.34-1.17.33,1.24-4.34,1.17-.33-1.24Zm16-77.88,3.56,2.75-.77,1-3.56-2.75.77-1Zm152.94,90.21-4.15-1.73.49-1.18,4.15,1.73-.49,1.18ZM215,19.9l1.16,4.36-1.23.33-1.16-4.36L215,19.9Zm57.35,4.19-1.72,4.17-1.18-.49,1.72-4.17,1.18.49Zm-45.86-6.4.59,4.48-1.26.16-.59-4.47,1.26-.17Zm34.81,2.54-1.16,4.36-1.23-.33,1.16-4.36,1.23.33ZM151.31,83l4.34,1.17-.33,1.24L151,84.25l.33-1.24Zm14.9,78.08,3.56-2.75.78,1L167,162.11l-.77-1ZM292.5,36l-2.73,3.58-1-.78,2.73-3.58,1,.78ZM155.16,71.9l4.15,1.73-.49,1.19-4.15-1.73.49-1.19Zm94.69-54-.59,4.47L248,22.16l.59-4.48,1.26.17Zm74.24,66.39-4.34,1.17-.33-1.24L323.75,83l.33,1.24Zm-.33,46.53-4.34-1.17.33-1.24,4.34,1.17-.33,1.24Zm-23.42,40.16-3.17-3.19.9-.91,3.18,3.19-.9.91Zm25.95-75.13-4.45.58-.16-1.27,4.45-.59.16,1.27ZM149,94.51l4.45.59-.16,1.27-4.45-.59.17-1.27Zm159.14,67.62-3.56-2.75.77-1,3.56,2.75-.77,1ZM183.59,35.19l2.73,3.58-1,.78L182.58,36l1-.78ZM203.9,23.6l1.72,4.17-1.18.49-1.72-4.17,1.18-.49ZM154.67,140.71l4.15-1.73.48,1.19-4.15,1.73-.48-1.19Zm154.2-88-3.56,2.75-.77-1,3.56-2.75.77,1Zm11.53,20.4-4.15,1.73-.48-1.18,4.15-1.73.48,1.18ZM174.74,42.88l3.17,3.19-.9.9-3.18-3.19.91-.9Zm126.5.9L298.06,47l-.91-.91,3.18-3.19.9.91ZM173.86,170l3.17-3.19.9.91-3.18,3.19Z" fill="#999"/>
<g id="speedControl">
<circle id="knobBase" cx="237.54" cy="103.97" r="70" fill="#333"/>
<circle id="knobRing" cx="237.54" cy="103.97" r="71" fill="none" stroke="#1a1a1a" stroke-miterlimit="10" stroke-width="2"/>
<circle id="knobRingHighlight" cx="237.54" cy="103.97" r="69" fill="none" stroke="#3fa9f5" stroke-miterlimit="10"/>
<path id="indicator" d="M237.54,50.49a5.37,5.37,0,1,0-5.37-5.37A5.38,5.38,0,0,0,237.54,50.49Z" fill="#fff" fill-rule="evenodd"/>
<text transform="translate(205.29 86.54)" font-size="19.38" fill="#fff" >TWEEN<tspan x="2.77" y="23.25">SPEED</tspan><tspan x="-11.84" y="46.51">CONTROL</tspan></text>
</g>
<g id="playButton">
<path d="M66.44,96.54a29.07,29.07,0,0,1,0-58.14h32a29.07,29.07,0,1,1,0,58.14Z" fill="url(#linear-gradient-11)"/>
<path d="M66.44,91a23.53,23.53,0,0,1,0-47.07h32a23.53,23.53,0,1,1,0,47.07Z"/>
<path d="M66.44,89.62a22.15,22.15,0,0,1,0-44.3h32a22.15,22.15,0,1,1,0,44.3Z" fill="url(#linear-gradient-12)"/>
<text class="play" transform="translate(58.81 73.02)" font-size="19.38" fill="#3fa9f5" >PLAY</text>
</g>
<g id="pauseButton">
<path d="M66.44,168.54a29.07,29.07,0,0,1,0-58.14h32a29.07,29.07,0,1,1,0,58.14Z" fill="url(#linear-gradient-13)"/>
<path d="M66.44,163a23.53,23.53,0,0,1,0-47.07h32a23.53,23.53,0,0,1,0,47.07Z"/>
<path d="M66.44,161.62a22.15,22.15,0,0,1,0-44.3h32a22.15,22.15,0,0,1,0,44.3Z" fill="url(#linear-gradient-14)"/>
<text class="pause" transform="translate(52.52 145.02)" font-size="19.38" fill="#fff" opacity="0.35" >PAUSE</text>
</g>
<g id="handControlGroup">
<g id="handControl">
<g>
<path d="M388.81,88.85a13.48,13.48,0,0,1,0-27h46.32a13.48,13.48,0,0,1,0,27Z" fill="url(#linear-gradient-15)"/>
<path d="M388.81,83.94a8.58,8.58,0,0,1,0-17.15h46.32a8.58,8.58,0,0,1,0,17.15Z"/>
<path d="M388.81,82.72a7.35,7.35,0,0,1,0-14.7h46.32a7.35,7.35,0,0,1,0,14.7Z" fill="url(#linear-gradient-16)"/>
</g>
<g id="handSlider">
<g>
<path d="M390.4,87.62a12.26,12.26,0,0,1,0-24.5H408.1a12.26,12.26,0,0,1,0,24.5Z"/>
<path d="M418.85,75.37a11,11,0,0,1-10.75,11H390.4a11,11,0,0,1,0-22.05H408.1A11,11,0,0,1,418.85,75.37Z" fill="url(#linear-gradient-17)"/>
<path d="M390.4,83.94a8.58,8.58,0,0,1,0-17.15H408.1a8.58,8.58,0,0,1,0,17.15Z" fill="url(#linear-gradient-18)"/>
</g>
<text transform="translate(387.07 77)" font-size="8" fill="#fff" >CLICK</text>
</g>
</g>
<text class="off" transform="translate(347.19 79.87)" opacity="0.35" font-size="11" fill="#fff" >OFF</text>
<text class="on" transform="translate(456.73 79.87)" font-size="11" fill="#3fa9f5" >ON</text>
<text transform="translate(373.14 49.34)" font-size="14" fill="#fff" >HAND ICON</text>
</g>
<g id="themeControlGroup">
<g id="themeControl">
<g>
<path d="M388.81,162.85a13.48,13.48,0,0,1,0-27h46.32a13.48,13.48,0,0,1,0,27Z" fill="url(#linear-gradient-19)"/>
<path d="M388.81,157.94a8.58,8.58,0,0,1,0-17.15h46.32a8.58,8.58,0,0,1,0,17.15Z"/>
<path d="M388.81,156.72a7.35,7.35,0,0,1,0-14.7h46.32a7.35,7.35,0,0,1,0,14.7Z" fill="url(#linear-gradient-20)"/>
</g>
<g id="themeSlider">
<g>
<path d="M390.4,161.62a12.26,12.26,0,0,1,0-24.5H408.1a12.26,12.26,0,0,1,0,24.5Z"/>
<path d="M418.85,149.37a11,11,0,0,1-10.75,11H390.4a11,11,0,0,1,0-22.05H408.1A11,11,0,0,1,418.85,149.37Z" fill="url(#linear-gradient-21)"/>
<path d="M390.4,157.94a8.58,8.58,0,0,1,0-17.15H408.1a8.58,8.58,0,0,1,0,17.15Z" fill="url(#linear-gradient-22)"/>
</g>
<text transform="translate(387.07 152)" font-size="8" fill="#fff" >CLICK</text>
</g>
</g>
<text class="dark" transform="translate(342.65 153.87)" font-size="11" fill="#3fa9f5" >DARK</text>
<text class="light" transform="translate(453.91 153.87)" opacity="0.35" font-size="11" fill="#fff" >LIGHT</text>
<text transform="translate(364.09 123.34)" font-size="14" fill="#fff" >BACKGROUND</text>
</g>
</svg>
</div>
body,
html {
width: 100%;
height: 100%;
overflow: hidden;
margin: 0;
padding: 0;
background: #7a7a7a;
}
#demo {
font-family: 'Roboto', sans-serif;
position: absolute;
left: 50%;
opacity: 0;
visibility: hidden;
overflow: hidden;
}
#controls {
font-family: 'Roboto', sans-serif;
font-weight: 700;
width: 650px;
position: absolute;
left: 50%;
height: 200px;
z-index: 100;
opacity: 0;
visibility: hidden;
}
#pauseButton,
#playButton,
#themeControl,
#handControl,
#swatches rect,
#speedControl {
cursor: pointer;
}
const demo = document.querySelector("#demo");
const controls = document.querySelector("#controls");
const colorArray = ["#46a4cc", "#94c356", "#eae047", "#a63e4b", "#e3aa59", "#a63ba0", "#a2a2a2", "#4c42d1", "#cf5b21"];
const swatches = gsap.utils.toArray("#swatches rect");
let speed = 1;
const tl = gsap.timeline({repeat:-1, defaults:{ease:"none"}});
const ease2 = "power2.inOut";
const highlight = "#3fa9f5";
// basic alignment and initial color settings
gsap.set([controls, demo], {transformOrigin:"center center", xPercent:-50, autoAlpha:1});
gsap.set("#hand", { yPercent:-100, transformOrigin:"center center"});
gsap.set("#handSlider", { x:26});
gsap.set(".theWords path", {stroke:colorArray[0], drawSVG:0});
gsap.set("#speedControl", {transformOrigin:"center center"});
gsap.set(".theWords ellipse", {autoAlpha:0, fill:colorArray[0]});
gsap.set("#groupSizer", {autoAlpha:0});
swatches.forEach((obj, i) => {
obj.index = i;
gsap.set(obj, {fill:colorArray[i]})
obj.addEventListener("click", changeColor);
});
// toggle control timelines
const iconTl = gsap.timeline({reversed: true, paused:true, defaults:{ease:"none", duration:0.35}});
iconTl.to("#handSlider", {x:0, ease:"power4.inOut"});
iconTl.to("#hand", {autoAlpha:0},0);
iconTl.to(".off", {opacity:1, fill:highlight}, 0);
iconTl.to(".on", {opacity:0.35, fill:"#fff"}, 0);
const themeTl = gsap.timeline({reversed: true, paused:true, defaults:{ease:"none", duration:0.4}});
themeTl.to("#themeSlider", {x:26, ease:"power4.inOut"});
themeTl.to("#bg", {fill:"#fff"}, 0);
themeTl.to(".light", {opacity:1, fill:highlight}, 0);
themeTl.to(".dark", {opacity:0.35, fill:"#fff"}, 0);
// button listeners
document.querySelector("#playButton").addEventListener("click", playTimeline);
document.querySelector("#pauseButton").addEventListener("click", pauseTimeline);
document.querySelector("#handControl").addEventListener("click", function() {
toggle(iconTl)
});
document.querySelector("#themeControl").addEventListener("click", function() {
toggle(themeTl)
});
// create the tween speed draggable
Draggable.create("#speedControl", {
type:"rotation",
bounds: {
minRotation:-136,
maxRotation: 136
},
onDrag: speedUpdate
}); // end draggable create
// adjust the animation timeScale()
function speedUpdate() {
let r = this.rotation;
if (r < 0) {
speed = 1+(r/150);
} else {
speed = (r/25)+1;
}
tl.timeScale(speed.toFixed(2));
}
// timeline play/pause controls
function playTimeline() {
if (tl.paused() ) {
tl.play();
gsap.to(tl, {duration: 0.75, timeScale:speed});
gsap.to(".play", {duration: 0.4, fill:highlight, opacity:1, ease:"none"});
gsap.to(".pause", {duration: 0.4, fill:"#fff", opacity:0.35, ease:"none"});
}
}
function pauseTimeline() {
if (!tl.paused() ) {
gsap.to(tl, 0.75, {
timeScale:0,
onComplete: function() {
tl.pause();
}
});
gsap.to(".pause", {duration: 0.4, fill:highlight, opacity:1, ease:"none"});
gsap.to(".play", {duration: 0.4, fill:"#fff", opacity:0.35, ease:"none"});
}
}
// function for the toggle switch timelines
function toggle(t) {
t.reversed() ? t.play() : t.reverse();
}
//change the color of the stroke and dots
function changeColor() {
let newColor = colorArray[ this.index ];
gsap.to( ".theWords path", { duration: 1, stroke:newColor, ease:"none" });
gsap.to( ".theWords ellipse", { duration: 1, fill:newColor, ease:"none" });
}
// main timeline creation
tl.to("#hPipe", {duration: 0.35, drawSVG:true});
tl.to("#hand", {duration: 0.35, motionPath:{path:"#hPipe", align:"#hPipe"}}, 0);
// move to second part of h
tl.to("#hand", {duration: 0.25, x:364.08, y:140.94, ease:ease2 });
// start main h body
tl.add("path2");
tl.to("#hBody", {duration: 0.75, drawSVG:true}, "path2");
tl.to("#hand", {duration: 0.75, motionPath:{path:"#hBody", align:"#hBody"} }, "path2");
//move to main path of 'handwriting'
tl.to("#hand", { duration: 0.25, x:430.67, y:293.63, ease:ease2 });
// start rest of first word
tl.add("path3");
tl.to("#mainPath", {duration: 5, drawSVG:true}, "path3");
tl.to("#hand", { duration: 5, motionPath:{path:"#mainPath", align:"#mainPath"} }, "path3");
// move to first dot over i
tl.to("#hand", { duration: 0.5, x:926, y:271.97, ease:ease2 });
tl.to("#dot2", {duration: 0.15, autoAlpha:1});
// move to horizontal cross on t
tl.to("#hand", { duration: 0.3, x:936.82, y:232.3, ease:ease2 });
// start cross of t
tl.add("path4");
tl.to("#tCross", {duration: 0.25, drawSVG:true}, "path4");
tl.to("#hand", { duration: 0.25, motionPath:{path:"#tCross", align:"#tCross"} }, "path4");
// move to second i dot
tl.to("#hand", { duration: 0.1, x:1056.39, y:271.97, ease:ease2 });
tl.to("#dot1", {duration: 0.15, autoAlpha:1});
// mpve to beginning of 'is'
tl.to("#hand", { duration: 0.4, x:474.84, y:432, ease:ease2 });
// start is path
tl.add("path5");
tl.to("#isPath", {duration: 0.75, drawSVG:true}, "path5");
tl.to("#hand", { duration: 0.75, motionPath:{path:"#isPath", align:"#isPath"} }, "path5");
// move to dot of the i in 'is'
tl.to("#hand", { duration: 0.25, x:475.71, y:406.97, ease:ease2 });
tl.to("#dot3", {duration: 0.15, autoAlpha:1});
// move to beginning of 'easy'
tl.to("#hand", { duration: 0.25, x:706, y:468.5, ease:ease2 });
// start 'easy' path
tl.add("path6");
tl.to("#easyPath", {duration: 2, drawSVG:true}, "path6");
tl.to("#hand", { duration: 2, motionPath:{path:"#easyPath", align:"#easyPath"} }, "path6");
// move to period at end of sentence
tl.to("#hand", { duration: 0.25, x:1022.7, y:488.51, ease:ease2 });
tl.to("#dot4", {duration: 0.15, autoAlpha:1});
// move hand out of the way
tl.to("#hand", { duration: 0.75, x:1300, y:675, ease:ease2 });
// move to beginning and fade out text for a seamless loop
tl.add("ending", "+=1");
tl.to("#hand", { duration: 1, x:236.07, y:153.69, ease:ease2 }, "ending");
tl.to(".theWords path, .theWords ellipse", {duration: 0.75, autoAlpha:0}, "ending");
// resize and center SVG demo and controls
function sizeAll() {
let h = window.innerHeight;
let w = window.innerWidth;
if ( w > (h-250)*2) {
gsap.set(demo, {height:h-240, width:(h-250)*2});
gsap.set(controls, {y:h-240});
} else {
gsap.set(demo, {y:0, width:w-10, height:w/2});
gsap.set(controls, {y:w/2+10});
}
}
window.addEventListener('resize', sizeAll);
sizeAll();
Also see: Tab Triggers