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.
<div class="float">
For best stereo effect, use headphones!
<button onclick="toggleSound(this)">
<h3>Start sound</h3></button>
</div>
<svg id="svg" viewPort="0 0 600 500" version="1.1" xmlns="http://www.w3.org/2000/svg">
<path
id="orbit"
d="M-150,100a400,100 0 1,0 800,0a400,100 0 1,0 -800,0"
visibility="hidden"
/>
<g id="cow">
<animateMotion begin="0s" dur="30s" repeatCount="indefinite">
<mpath xlink:href="#orbit" />
</animateMotion>
<animateTransform
xlink:href="#cow"
attributeName="transform"
attributeType="XML"
type="scale"
calcMode="spline"
values="1; 2; 1; 0.1; 1"
keyTimes="0; 0.25; 0.5; 0.75; 1"
keySplines="0 0 0.58 1;
0.42 0 1 1;
0 0 0.58 1;
0.42 0 1 1"
dur="30s"
begin="0s"
repeatCount="indefinite"
fill="freeze" />
<circle fill-rule="evenodd" clip-rule="evenodd" fill="purple" stroke="gray" r="157" cx="180" cy="300" />
<defs
id="defs921">
<linearGradient
id="linearGradient2791">
<stop
style="stop-color:#000000;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop2792" />
<stop
style="stop-color:#2e2e46;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop2793" />
</linearGradient>
<linearGradient
id="linearGradient2797">
<stop
style="stop-color:#ff00ff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop2798" />
<stop
style="stop-color:#66667d;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop2799" />
</linearGradient>
<linearGradient
id="linearGradient4049">
<stop
style="stop-color:#ff00ff;stop-opacity:0.45882353;"
offset="0.0000000"
id="stop4050" />
<stop
style="stop-color:#76768d;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop4051" />
</linearGradient>
<linearGradient
id="linearGradient2624">
<stop
style="stop-color:#000000;stop-opacity:0.0000000;"
offset="0.0000000"
id="stop2625" />
<stop
style="stop-color:#000000;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop2626" />
</linearGradient>
<linearGradient
id="linearGradient3587">
<stop
style="stop-color:#000000;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop3588" />
<stop
style="stop-color:#000000;stop-opacity:1.0000000;"
offset="0.50000000"
id="stop3595" />
<stop
style="stop-color:#000000;stop-opacity:0.0000000;"
offset="1.0000000"
id="stop3589" />
</linearGradient>
<linearGradient
id="linearGradient3591">
<stop
style="stop-color:#ff00ff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop3592" />
<stop
style="stop-color:#ff00ff;stop-opacity:0.49803922;"
offset="0.50000000"
id="stop3596" />
<stop
style="stop-color:#000000;stop-opacity:0.0000000;"
offset="1.0000000"
id="stop3593" />
</linearGradient>
<linearGradient
id="linearGradient3613">
<stop
style="stop-color:#100049;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop3614" />
<stop
style="stop-color:#090029;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop3616" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#000000"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="398.9276"
inkscape:cy="191.50547"
inkscape:window-width="1022"
inkscape:window-height="715"
inkscape:window-x="705"
inkscape:window-y="243"
inkscape:current-layer="svg919"
showgrid="false"
fit-margin-top="10"
fit-margin-left="10"
fit-margin-right="10"
fit-margin-bottom="10"
inkscape:window-maximized="0" />
<metadata
id="metadata922">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Larry the Cow</dc:title>
<dc:creator>
<cc:Agent>
<dc:title>Matteo 'Peach' Pescarin</dc:title>
</cc:Agent>
</dc:creator>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/2.5/" />
<dc:contributor>
<cc:Agent>
<dc:title>Ethan Dunham of Fonthead Design Inc. for Larry's Head</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/2.5/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
id="layer1"
inkscape:label="Larry"
transform="translate(-1.3240382,-4.4419361)"
sodipodi:insensitive="true">
<g
id="g2339">
<path
id="path2650"
style="fill:#ff00ff;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:0.70850501pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 363.94514,170.68073 c 0,0 -48.55342,18.45025 -80.59874,25.24779 -32.04526,6.79747 -71.85906,-3.88431 -82.54084,-3.88431 -10.68177,0 -13.595,-16.50817 -20.39247,-12.62386 -6.79747,3.88424 -16.50817,3.88424 -20.39248,21.36348 -3.88423,17.47925 -12.02718,51.44963 -16.50816,60.20628 -0.53127,10.07559 -2.49973,16.53237 -3.02469,26.8366 0.45414,13.2658 -5.01268,29.09061 -5.01268,29.09061 l -5.82647,1.94216 c 0,0 -4.85531,11.65278 -1.94208,19.42132 2.91316,7.76862 5.82639,12.62393 5.82639,12.62393 l 2.91323,-13.59493 0.97108,18.45025 c 0,0 4.85531,-6.79747 4.85531,-11.65278 0,-4.85539 1.94216,-12.62393 3.88431,-18.45033 1.94208,-5.82639 -6.79754,-6.79746 -6.79754,-6.79746 0,0 3.00324,-5.82646 5.23262,-27.88268 1.18644,-11.71612 3.7759,-22.21808 3.7759,-22.21808 0,0 0,6.79747 3.88424,18.45025 3.88431,11.65286 14.56608,24.27679 20.39247,28.16102 5.82639,3.88431 -2.91323,6.79754 -3.8843,10.68178 -0.97108,3.88431 3.8843,15.53709 8.73962,18.45032 4.85538,2.91323 11.65285,10.68177 14.56608,16.50816 2.91316,5.82647 9.7107,23.30571 10.68178,28.16102 0.971,4.85539 -1.94216,20.39248 -1.94216,20.39248 0,0 5.82639,0.97108 9.7107,0.97108 3.88424,0 11.65278,0 11.65278,0 l -1.94208,-7.76855 4.85531,7.76855 4.85532,-0.97108 -6.79747,-19.4214 c 0,0 -4.85531,-22.33463 -8.73962,-32.04526 -1.94208,-4.85538 -1.09237,-2.30632 -1.30486,-10.3176 1.30486,-0.84971 7.61679,-5.21956 11.5011,-9.10379 3.8843,-3.88431 9.71069,-13.10947 9.99551,-13.63901 0.28475,-0.52953 49.03691,1.53044 54.53009,1.53044 5.49325,0 11.67305,-2.74659 18.53959,-4.80649 6.86648,-2.05998 10.98636,-5.49318 13.73296,-6.86648 -1.3733,8.23977 -1.3733,8.23977 -0.68669,17.85284 0.68669,9.61307 3.43328,21.28611 4.80657,26.09268 1.3733,4.80657 13.04634,35.70582 13.04634,35.70582 l 0.68668,15.10624 c 0,0 10.98637,3.43328 15.10632,4.11989 4.11989,0.68668 13.04634,-1.37329 13.04634,-1.37329 l 0,-6.86648 c 0,0 5.49318,-0.68661 8.92639,-0.68661 3.43327,0 4.11995,-6.17987 4.11995,-6.17987 0,0 -2.74666,-15.10632 -3.43327,-19.91281 -0.68668,-4.80657 2.05998,-21.28619 5.49325,-31.58594 3.4332,-10.29975 10.29968,-27.46597 11.67298,-41.19892 1.37336,-13.73303 -4.8065,-46.69218 -4.8065,-46.69218 l -7.55316,-7.55316"
sodipodi:nodetypes="cccccccccccccccccccccccccccccccccccccccccccccccccccc"
transform="translate(-115,-13.75)"
inkscape:connector-curvature="0" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:0.70850501pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 216.82819,335.76247 c -5.82646,4.36984 -4.61258,3.27733 -6.37265,9.7107 -1.76007,6.43336 0.78899,16.02269 2.48834,21.84909 3.39877,11.65278 9.7107,29.61756 6.79754,30.58864 -2.91323,0.97107 -6.79754,1.45661 -10.68177,1.94215 -3.88431,0.48554 -2.91323,-4.36985 -2.91323,-8.25408 0,-3.88431 -3.88424,-21.84909 -7.76855,-28.64656 -3.88431,-6.79747 -4.36985,-18.45032 -10.19624,-21.84909 -5.82639,-3.3987 -12.62386,-5.34085 -13.10939,-8.25408 -0.48554,-2.91316 1.94208,-7.28301 4.36977,-10.68171 2.42769,-3.39877 7.76855,-1.94215 7.76855,-1.94215 0,0 0,-5.34093 -1.45662,-9.22516 -1.45654,-3.88431 -5.34085,0 -12.62386,-13.10947 -7.283,-13.1094 -12.13839,-29.61756 -12.13839,-37.87165 0,-8.25415 9.22516,-24.27678 9.7107,-31.55979 0.48554,-7.283 3.88431,8.73963 10.19624,10.68178 6.31193,1.94215 -7.76855,5.82639 -5.34086,18.45032 2.42763,12.62386 11.16725,26.21886 21.36349,28.16102 10.19623,1.94208 20.39247,2.91316 26.21886,-1.94216 5.82646,-4.85538 7.28301,-7.283 7.28301,-7.283 0,0 6.312,5.34085 3.39877,13.1094 -2.4277,26.7044 -11.16725,41.75595 -16.99371,46.1258 z"
id="path2647"
sodipodi:nodetypes="cszccccccccccccccccccc"
transform="translate(-115,-13.75)"
inkscape:connector-curvature="0" />
<path
id="path2655"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:0.70850501pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 237.62366,315.58077 c 0,0 4.8065,0 4.8065,0 0,0 54.93202,4.11989 58.36523,2.74659 3.43327,-1.37329 15.10631,-6.86647 17.8529,-8.92645 2.7466,-2.05991 -4.80656,-20.5995 -4.80656,-26.77929 0,-6.17987 0,-24.03278 0,-24.03278 0,0 4.11995,-4.11988 6.17986,-0.68661 2.05998,3.4332 4.11989,8.92638 4.11989,8.92638 -2.74659,17.85291 2.05997,36.39243 3.43327,44.63228 1.37329,8.23977 2.74659,39.82563 4.11988,46.69218 1.3733,6.86647 13.04635,28.15258 13.04635,31.58586 0,3.43327 0,12.35966 0,12.35966 0,0 8.92645,3.43327 11.67304,1.37336 2.74659,-2.05998 5.49318,-2.74666 5.49318,-2.74666 0,0 1.3733,-8.23977 -1.37329,-12.35966 -2.74659,-4.11988 -3.43321,-9.61306 -4.8065,-16.47961 -1.3733,-6.86648 -1.3733,-19.91282 0,-32.27247 1.37329,-12.35973 3.4332,-13.73303 2.05991,-19.22621 -1.3733,-5.49318 -2.7466,-41.199 -2.7466,-41.199 0,0 6.86648,-6.86647 7.55316,-2.74659 0.68662,4.11989 2.74659,13.04634 2.74659,13.04634 0,0 2.7466,-6.86647 8.23978,-12.35973 5.49325,-5.49318 8.23984,-25.40599 8.23984,-25.40599 0,0 -0.68668,-2.74659 -0.68668,-2.74659 L 368.08707,217.38984 361.9072,180.3108 c 0,0 -10.29975,3.4332 -15.79293,5.49318 -5.49318,2.05998 -17.16623,4.80657 -23.34609,6.86648 -6.17986,2.05998 -12.35966,2.05998 -12.35966,2.05998 l -7.55316,9.61306 c -4.11988,7.55316 3.43328,9.61314 6.17987,24.71939 2.74659,15.10632 -4.11996,17.85291 -9.61314,19.2262 -5.49318,1.3733 -10.29975,7.55316 -15.79293,19.22621 -5.49318,11.67304 -7.55316,20.5995 -13.04634,24.71938 -5.49318,4.11989 -12.35966,2.05998 -18.53952,0 -6.17987,-2.05998 -6.86655,-0.68668 -6.86655,-0.68668 0,0 -0.68661,-6.17979 -1.37329,2.05998 -0.68662,8.23977 -6.1798,21.97279 -6.1798,21.97279 z"
sodipodi:nodetypes="cccccccccccccccccccccccccccccccccccccc"
transform="translate(-115,-13.75)"
inkscape:connector-curvature="0" />
<g
id="g1550"
transform="matrix(0.43221,0,0,0.43221,128.5923,-74.87833)">
<path
style="fill:#ff00ff;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 72.698128,436.22755 c 0,0 30.230902,-39.58809 45.346362,-48.94527 15.11545,-9.35719 43.187,-17.99459 43.187,-17.99459 0,0 28.79134,-0.71978 44.62658,2.87914 15.83523,3.59891 35.26938,14.39567 35.26938,14.39567 0,0 7.19784,-5.75827 12.23632,-7.19784 5.03849,-1.43957 11.51654,-3.59892 11.51654,-3.59892 0,0 2.87913,-43.90679 3.59892,-47.5057 0.71978,-3.59892 0.71978,-38.86831 2.87913,-51.82441 2.15935,-12.9561 7.91762,-33.11004 12.9561,-33.82982 5.03849,-0.71979 17.99459,28.07155 18.71437,35.26939 0.71978,7.19783 11.51654,61.18159 15.11545,70.53877 3.59892,9.35719 8.6374,17.27481 8.6374,17.27481 0,0 23.03307,-5.03849 40.30788,-5.03849 17.2748,0 44.62657,3.59892 44.62657,3.59892 0,0 2.87913,2.15935 7.19784,0.71978 4.3187,-1.43956 5.03848,-2.15935 5.03848,-2.15935 0,0 23.75285,-35.98917 23.75285,-67.65964 0,-31.67047 -12.9561,-81.33553 -12.9561,-81.33553 0,0 -2.87913,-5.75827 0,-6.47805 2.87913,-0.71979 22.31329,10.79675 28.79134,28.07155 6.47805,17.2748 24.47264,45.34636 26.63199,59.02224 2.15935,13.67589 -6.47805,56.8629 -13.67589,64.78051 -7.19783,7.91762 -12.23632,17.99459 -8.6374,20.87372 3.59892,2.87914 9.35718,2.87914 14.39567,-0.71978 5.03848,-3.59892 48.22549,-39.58809 76.29704,-46.78592 28.07156,-7.19784 33.11004,-6.47805 43.18701,-6.47805 10.07697,0 22.31329,8.6374 22.31329,8.6374 0,0 17.99458,2.15935 28.79134,12.9561 10.79675,10.79675 17.2748,20.87372 9.35718,28.79134 -7.91762,7.91762 -20.15394,23.75285 -25.19242,23.75285 -5.03848,0 -4.3187,-1.43957 -4.3187,-1.43957 0,0 -24.47264,20.87372 -51.10463,23.75286 -26.63198,2.87913 -44.62657,3.59891 -59.74202,0.71978 -15.11545,-2.87913 -23.03307,-6.47805 -23.03307,-6.47805 0,0 11.51653,28.79134 12.9561,38.86831 1.43957,10.07696 10.79675,47.5057 11.51654,60.46181 0.71978,12.9561 6.47805,77.01682 6.47805,77.01682 0,0 7.19783,56.8629 10.07696,70.53878 2.87914,13.67589 10.07697,60.46181 5.75827,80.61575 -4.3187,20.15393 -5.03848,29.51112 -10.79675,35.98917 -5.75827,6.47805 -15.83524,15.83524 -23.75285,17.2748 -7.91762,1.43957 -27.35177,0.71979 -41.74744,6.47805 -14.39567,5.75827 -54.70355,28.79134 -68.37943,28.79134 -13.67589,0 -29.51112,-16.55502 -29.51112,-16.55502 0,0 -11.51654,-15.83523 -18.71437,-23.75285 -7.19784,-7.91762 -47.50571,-38.14852 -64.06073,-79.89596 -16.55502,-41.74744 -24.47264,-115.16536 -24.47264,-115.16536 0,0 -4.3187,-71.97834 -12.23631,-98.61033 -7.91762,-26.63198 -19.43416,-58.30246 -19.43416,-58.30246 0,0 -35.98917,32.39026 -82.05531,29.51113 -46.06614,-2.87914 -77.736612,-33.82983 -77.736612,-33.82983 z"
id="path2603"
inkscape:connector-curvature="0" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
d="m 104.3686,437.66712 48.22549,14.39567 c 0,0 40.30787,-15.11545 46.78592,-17.2748 6.47806,-2.15935 9.35719,-5.75827 14.39567,-7.19784 5.03849,-1.43957 14.39567,-4.3187 14.39567,-4.3187 l -0.71978,-10.07697 c 0,0 -11.51654,-2.15935 -27.35177,0 -15.83524,2.15935 -83.49488,17.27481 -89.25315,18.71437 -5.75827,1.43957 -6.47805,5.75827 -6.47805,5.75827 z"
id="path920"
inkscape:connector-curvature="0" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
d="m 142.51712,396.63946 74.1377,-0.71978 c 0,0 -16.55502,-8.6374 -36.70896,-8.6374 -20.15394,0 -37.42874,9.35718 -37.42874,9.35718 z"
id="path921"
inkscape:connector-curvature="0" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
d="M 314.54537,369.28769 304.4684,348.41397 c 0,0 -0.71979,-9.35718 -3.59892,-20.87372 -2.87913,-11.51653 -7.19783,-17.99458 -7.19783,-17.99458 0,0 -5.75827,7.91761 -6.47806,14.39567 -0.71978,6.47805 -0.71978,25.19242 -1.43956,29.51112 -0.71979,4.3187 -5.03849,9.35718 -0.71979,14.39567 4.31871,5.03848 7.19784,6.47805 10.79676,6.47805 3.59891,0 12.23631,-4.3187 12.23631,-4.3187 l 6.47806,-0.71979 z"
id="path922"
inkscape:connector-curvature="0" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
d="m 437.62833,362.08986 c 0,0 13.67589,3.59892 17.27481,0.71978 3.59891,-2.87913 10.79675,-13.67588 10.79675,-13.67588 0,0 2.15935,-22.31329 3.59892,-33.82983 1.43956,-11.51653 2.87913,-18.71437 2.87913,-18.71437 0,0 -2.15935,-6.47805 -3.59892,-11.51653 -1.43956,-5.03848 -5.03848,-12.23632 -5.03848,-12.23632 l -5.03849,-15.11545 c 0,0 1.43957,15.11545 0,20.15394 -1.43956,5.03848 -0.71978,20.15393 -2.15935,28.79133 -1.43956,8.6374 -6.47805,34.54961 -10.07696,39.58809 -3.59892,5.03849 -8.63741,15.83524 -8.63741,15.83524 z"
id="path923"
inkscape:connector-curvature="0" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
d="m 507.44733,400.95816 c 0,0 2.87913,-10.07696 10.79675,-12.9561 7.91762,-2.87913 38.86831,-7.19783 46.06614,-7.19783 7.19784,0 25.91221,0 25.91221,0 0,0 5.75826,-5.03849 14.39566,-5.03849 8.63741,0 20.87372,0 20.87372,0 0,0 -7.91761,9.35719 -12.9561,12.23632 -5.03848,2.87914 -13.67588,3.59892 -17.2748,7.19784 -3.59892,3.59891 -19.43415,10.79675 -35.26939,12.23632 -15.83524,1.43956 -39.58809,0.71978 -39.58809,0.71978 l -12.9561,-7.19784 z"
id="path924"
inkscape:connector-curvature="0" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
d="m 519.68365,376.48553 c 0,0 21.5935,-10.79675 41.02765,-12.9561 19.43416,-2.15936 57.58268,-3.59892 57.58268,-3.59892 0,0 -8.6374,-12.9561 -37.42874,-10.07697 -28.79134,2.87913 -45.34636,9.35718 -51.82441,14.39567 -6.47805,5.03848 -9.35718,12.23632 -9.35718,12.23632 z"
id="path925"
inkscape:connector-curvature="0" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
d="m 351.25432,763.72902 c 0,0 24.47264,-36.70895 68.37943,-52.54419 43.90679,-15.83524 91.4125,-9.35719 91.4125,-9.35719 0,0 2.15935,-13.67588 -0.71979,-23.75285 -2.87913,-10.07697 -2.87913,-10.07697 -2.87913,-10.07697 l -2.15935,-4.3187 c 0,0 0,-23.75285 -2.15935,-36.70895 -2.15935,-12.95611 -15.83524,-95.01142 -15.83524,-95.01142 0,0 0.71979,-26.63199 -2.15935,-37.42874 -2.87913,-10.79675 -10.79675,-35.26939 -10.79675,-40.30787 0,-5.03848 2.15935,-8.6374 2.15935,-8.6374 0,0 -3.59892,-12.9561 -5.75827,-18.71437 -2.15935,-5.75827 -3.59891,-10.79675 -3.59891,-10.79675 0,0 -32.39026,-25.91221 -60.46181,-30.95069 -28.07156,-5.03849 -59.02225,0 -68.37943,0 -9.35719,0 -50.38484,9.35718 -55.42333,9.35718 -5.03848,0 -32.39025,3.59892 -33.82982,15.11546 -1.43956,11.51653 17.2748,44.62657 17.2748,44.62657 0,0 5.03849,24.47264 7.91762,31.67047 2.87914,7.19784 10.79675,42.46722 12.23632,61.90138 1.43957,19.43415 9.35719,102.20925 12.9561,116.60492 3.59892,14.39566 7.91762,41.02765 16.55502,56.1431 8.6374,15.11546 17.99459,28.79134 23.03307,33.11004 5.03849,4.3187 12.23632,10.07697 12.23632,10.07697 z"
id="path926"
inkscape:connector-curvature="0" />
<path
style="fill:#ff00ff;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 340.45757,516.12352 c 0,0 -14.39567,-2.15935 -25.19242,8.6374 -10.79675,10.79675 -13.67589,13.67588 -11.51654,20.15393 2.15935,6.47805 2.15935,10.79676 6.47806,13.67589 4.3187,2.87913 8.6374,7.19783 12.9561,7.19783 4.3187,0 19.43415,-9.35718 24.47263,-12.23632 5.03849,-2.87913 12.23632,-11.51653 9.35719,-17.2748 -2.87913,-5.75827 -3.59892,-12.9561 -7.91762,-15.83523 -4.3187,-2.87914 -4.3187,-2.87914 -8.6374,-4.3187 z"
id="path927"
inkscape:connector-curvature="0" />
<path
style="fill:#ff00ff;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 423.23267,494.53001 c 10.79675,1.43957 14.39566,-1.43956 15.83523,-5.75827 1.43957,-4.3187 4.3187,-17.2748 -8.6374,-17.2748 -12.9561,0 -15.83524,4.3187 -15.83524,10.79675 0,6.47805 2.87914,10.07697 8.63741,12.23632 z"
id="path928"
inkscape:connector-curvature="0" />
</g>
<path
id="path3578"
style="fill:#ff00ff;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:0.88749999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1"
d="m 138.76971,342.81301 3.76677,7.76985 c 0,0 3.43327,10.29975 6.17986,15.793 2.74659,5.49318 4.11989,19.22613 5.49318,21.97273 1.3733,2.74666 -4.80656,2.74666 -4.80656,2.74666 l -1.3733,-5.49326 -1.37329,6.17987 c 0,0 -4.11989,2.74659 -8.23978,2.05998 -4.11988,-0.68669 -13.73302,-0.68669 -14.41963,-3.43328 -0.68668,-2.74659 4.11988,-12.35965 4.11988,-12.35965 l 2.74659,-8.23985 -2.74659,-4.11988 -5.81705,-20.28964 c -0.32387,-0.37683 -2.19079,-4.15751 -6.71632,-9.42093 -3.74192,-4.35206 -6.62913,-7.53522 -11.00413,-9.41022 l 3.69639,-6.29441 9.28077,-11.93243 28.28427,0.88388 c 0,0 -0.44194,5.74525 -1.76776,11.93243 -1.32583,6.18718 -8.83884,11.93243 -8.83884,11.93243 l 3.53554,9.72272 z"
sodipodi:nodetypes="ccccccccccccccccccccc"
inkscape:connector-curvature="0" />
</g>
</g>
</g>
</svg>
html {
height: 100%;
}
body {
color: white;
background-color: black;
margin: 0;
overflow: hidden;
}
.float {
position: absolute;
}
svg {
width: 100vw;
height: 100vh;
}
.star {
position: absolute;
left: 0px;
background-color: white;
border-radius: 50%;
animation-name: moveX;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.small {
top: 10px;
width: 3px;
height: 3px;
animation-duration: 5s;
background-color: gray;
}
.medium {
top: 50px;
width: 4px;
height: 4px;
animation-duration: 4s;
}
.big {
left: 0px;
top: 100px;
width: 5px;
height: 5px;
animation-duration: 3s;
}
@keyframes moveX {
from {
transform: translateX(100vw);
}
to {
transform: translateX(-200px);
}
}
/*
Sick? Definitely!
*/
var isPlaying = false;
var audioContext;
var mooSound;
var gainNode;
var reverbNode;
var pannerNode;
var π = Math.PI;
var tick = 3/2*π;
var updateTime = 200;
var timeForOneRev = 30000;
// From 0 to 2π should take timeForOneRev ms
var increaseFactor = (π * 2) / (timeForOneRev / updateTime);
function updatePanValue() {
if(isPlaying) {
var panValue = Math.sin(tick);
pannerNode.pan.value = panValue;
var gainValue = (Math.cos(tick) / 2 + 0.5) * 0.9 + 0.1;
gainNode.gain.value = gainValue;
}
tick += increaseFactor;
}
// http://stackoverflow.com/questions/21797299/convert-base64-string-to-arraybuffer
function base64ToArrayBuffer(base64) {
var binaryString = window.atob(base64);
var len = binaryString.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
return bytes.buffer;
}
function initSound() {
audioContext = new AudioContext();
// soundData is defined in another Pen
// It is an ogg file encoded as a Data URI
// (MIME type plus base64 string).
mooSound = new Audio(mooSoundDataUri);
mooSound.crossOrigin = "anonymous";
mooSound.loop = true;
var source = audioContext.createMediaElementSource(mooSound);
// The gain node lets us toggle sound on/off,
// but we also use it to increase volume when
// the object is near and decrease volume when
// far away.
gainNode = audioContext.createGain();
gainNode.gain.value = 0;
reverbNode = audioContext.createConvolver();
// impulseResponse is defined in another Pen
// It's a base64 encoded string.
// Convert it to a binary array first
var reverbSoundArrayBuffer = base64ToArrayBuffer(impulseResponse);
audioContext.decodeAudioData(reverbSoundArrayBuffer,
function(buffer) {
reverbNode.buffer = buffer;
},
function(e) {
alert("Error when decoding audio data" + e.err);
}
);
// Pans the sound left/right. Synced with the
// object's screen position.
pannerNode = audioContext.createStereoPanner();
// Connect the audio chain together
source.connect(gainNode);
gainNode.connect(pannerNode);
pannerNode.connect(reverbNode);
reverbNode.connect(audioContext.destination);
mooSound.play();
var intervalId = setInterval(updatePanValue, updateTime);
}
function toggleSound(toggleButton) {
isPlaying = !isPlaying;
if(isPlaying) {
toggleButton.innerHTML = "<h3>Stop sound!</h3>";
} else {
gainNode.gain.value = 0;
toggleButton.innerHTML = "<h3>Start sound</h3>";
}
}
function random(max) {
return Math.floor(Math.random() * max);
}
function addStar(type, zIndex) {
var div = document.createElement("div");
div.classList.add("star", type);
div.style.top = random(window.innerHeight) + "px";
div.style.zIndex = zIndex;
document.body.appendChild(div);
}
function initGraphics(){
for(var i = 0; i < 20; ++i) {
var delay = i * 333;
window.setTimeout(addStar, delay, "small", -200);
window.setTimeout(addStar, delay + 333, "medium", -100);
window.setTimeout(addStar, delay + 666, "big");
}
}
initSound();
initGraphics();
Also see: Tab Triggers