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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <!--
Chose not to use GUI because I wanted to keep the JS in it's simplest form, &&  I think this is a more intimate experience with the code, && so I could share a few comments && remain within my #50Liness||Less guidelines; also so anyone who may have fallen madly love with it can easily take it && enjoy. ;) 

Disclaimer: this is not, in any way, meant to be a tutorial. But seeing immediate results of the change in individual values within an equation is how I've been able to gain a deeper understanding of how math effects animation.

My var names are kept as letters because I wrote this with the intent of remixing it.  Some edits often change the purpose or effect the variable had initially, so it's easier to keep them somewhat anonymous

If you'd like to see all of the designs I've come up with so far you can check out the collection:

https://codepen.io/collection/DwaYBy/

Nautilus was the very first pen from this foundation.  I have since trimmed out some pieces of the code not currently needed.
!-->
<section class="wrap">
  <div class="column" id='code'>
    <div id='sP1'>
      <form>
        <span class='cm'>/*
    <br>I play with my code all the time to show other designs and motions that can come from it. This piece has been my favorite to remix so far && this pen demonstrates the effect very basic numeric changes can have. So much more can be done beyond this, but below are values that I think are the most fun to play with - without getting too in depth. Over there is a spiral design I made using this pen... 
    <br>
    <br>The x value on line 23 is controlling size,
    <br>so we'll leave that alone and play with y.
    <br>
    <br>We're at line 24:
    <br>
    <br> y = x * Math.sin(i + <span class='mn'>l</span> * t + x / 50) / <span class='mn'>m</span>;
        <br>
        <br> Playful <span class='mn'>l and m</span> are going to effect speed, angles && movement; the results of which are heavily influenced by line 34. Current values are shown; you may input new values below.
        <br>
        <br>*/</span>
        <br>
        <br> ...(i +
        <input type="number" id="l" value=3.4 step = "0.5"> ...x / 50)&nbsp;/&nbsp;
        <input type="number" id="m"  value=13 step = "0.5">;
        <br>
        <br><span class='cm'>/*<br><span class = 'mn'>b</span> is important, it's used in lines 25 && 26 to manipulate our _x, _y points. We define its value at line 34, where the real magic is:
        <br>
        <br> b = ( j * <span class='mn'>n</span>) * Math.PI / <span class='mn'> o</span>;
        <br>
        <br> j = loop counter from line 21 which we are multiplying by <span class='mn'>n</span>; consider <span class='mn'>n</span> our theta value. You can use <b>any</b> number.
        <br>
        <br>*/</span>
        <br>
        <br> ( j *
        <input type="number" id="j" value=2.86 step = "0.1"> )
        <br>
        <br> <span class='cm'>/*

    <br>o = our pi divider. We're going to muliply the result of ( j*<span class='mn'>n</span> ) by Math.PI, divided by some number <span class='mn'>o</span>.
        <br>You don't have to "know" what number to divide by.
        <br>Play with it.
        <br>
        <br>*/</span>
        <br />
        <br />Math.PI /
        <input type="number" id="pi" value=4 step = "0.05">
        <br><span class='cm'><b><br />/*<br />Bonus:</b> var <span class="mn">i</span> = num of layers. We use this as a counter on line 17:
        <pre><code>(var i = 0; i < <span class="mn">k</span>; i++)</code></pre> We want i to be less than some number <span class="mn">k</span>. Best results between .1 && 5
        <br />*/
        <br />
        </span>
        <br />
        <br /> i
        < <input type="number" id="ly" value=3 step = "0.1" min = .1> ;
          <br />
          <br /><span class='cm'>/*<br/>
      Bonus 2:
      You can adjust the width of the lines by entering a value for var <span class = 'mn'>lw</span> on line 20:
          <br />
          <br /> $.lineWidth = <span class='mn'>lw</span>;
          <br />
          <br /> Keep in mind that we are using the stroke(), which tends to hurt performance; sacrificing perf for width/line thickness. Keeping it below 2 is generally safe.
          <br />
          </br /> */
          </span>
          <br />
          <br /> $.lineWidth =
          <input type="number" id="lw" value=0.15 step = "0.1" min = 0> ;
          <br />
          <br /><span class='cm'>/* <br />
      Bonus 3:  
       We have little circles at the meeting of each angle. We can adjust the size of them by editing var <span class = 'mn'>r</span> within the arc() on line 34. For no circles, enter 0:
          <br />
          </br /> $.arc(w / 2 + _x, h / 2 + _y, <span class='mn'>r</span>, 0, 2 * Math.PI);
          <br />
          <br /> */
          </span>
          <br />
          </br /> $.arc(... + _y,
          <input type="number" id="rad" value=0.5 step = "0.1" min = 0>, ...);
          <br />
          <br />
          <span class='cm'>/*<br />Bonus 4:
   May as well mess with the color alpha; .01 to 1,  line 22. <br /><br />
   $.strokeStyle = 'hsla('+(u*2)+',100%,60%,'+<span class = 'mn'>a</span>+')';<br />
            <br /><span class = 'mn'>u</span> = our color update var; init @ 0 && incremented on line 40.  We'll just play with the alpha value <span class = 'mn'>a</span>.<br />
          <br />*/
          </span>
          <br />
          <br />$.strokeStyle = 'hsla(...%,
          <input type="number" id="alph"  value=0.6 step = .1 max = 1.0>)' ;
      </form>
      <br />
      <p class='cm'>/* Hope You've Been Entertained! */</p>
    </div>
  </div>

  <div class="column">
    <canvas id='canv'></canvas>
  </div>
</section>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400);

body {
  background: hsla(0, 0%, 5%, 1);
  margin: 0;
  width: 100%;
  overflow: auto;
  font-family: 'Source Code Pro', ;
  z-index: 1;
}

.column {
  flex-flow: column wrap;
  -webkit-flex-flow: column wrap;
  -moz-flex-flow: column wrap;
}

#code {
  height: 60%;
}

span.cm,
p.cm {
  color: hsla(170, 95%, 35%, 1);
}

#sP1 {
  color: hsla(0, 0%, 85%, 1);
  height: 100vh;
  background: hsla(0, 0%, 0%, .5);
  z-index: 5;
  overflow-y: scroll;
  line-height: 1.5em;
}

p {
  text-align: center;
  font-weight: bold;
  font-style: italic;
}

form {
  padding: 2% 3%;
}

form input {
  color: hsla(0, 0%, 5%, 1);
  width:5em;
  text-align: center;
  border: none;
  background: hsla(0, 0%, 90%, 1);
}

span.mn {
  color: orange;
}

canvas {
  width: 100%;
  height: 100%;
}

@media only screen and (min-width: 48em) {
  .wrap {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: -moz-box;
    display: box;
    display: flexbox;
    display: flex;
    flex-flow: row nowrap;
    -webkit-flex-flow: row nowrap;
    -moz-flex-flow: row nowrap;
    -webkit-justify-content: stretch;
    -ms-box-pack: stretch;
    -moz-justify-content: stretch;
    justify-content: stretch;
    flex: 1;
  }
  .column {
    margin: 0.5em;
    width: auto;
    -webkit-box-flex: 1;
    -moz-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
  }
}
              
            
!

JS

              
                var c = document.getElementById('canv'),
  $ = c.getContext('2d'),
  w = c.width = window.innerWidth/2,
  h = c.height = window.innerHeight,
  t = 0, num = 750, u=0,
  s, a, b, 
  x, y, _x, _y,
  _t = 1 / 60;

var anim = function() {
  $.globalCompositeOperation = 'source-over';
  window.requestAnimationFrame(anim);
  $.fillStyle = 'hsla(0, 0%, 5%, 1)';
  $.fillRect(0, 0, w, h);
  $.globalCompositeOperation = 'lighter';
  var k = document.getElementById("ly").value;
  for (var i = 0; i < k; i++) {
    x = 0;
    $.beginPath();
    
    for (var j = 0; j < num; j++) {
      $.strokeStyle = 'hsla('+(u*2)+',100%,60%,'+a+')';
      x += .5 * Math.sin(2);
      y = x * Math.sin(i + l * t + x /50) / m;
      _x = x * Math.cos(b) + y * Math.sin(i);
      _y = x * Math.sin(b) + y * Math.cos(i);
      var l = document.getElementById("l").value ;
      var m = document.getElementById("m").value ;
      var n = document.getElementById("j").value ;
      var o = document.getElementById("pi").value;
      var lw = document.getElementById("lw").value;
      var r = document.getElementById("rad").value;
      var a = document.getElementById('alph').value;
      b = (j*n) * Math.PI / o;
      $.lineWidth = lw;
    
      $.arc(w / 2 + _x, h / 2 + _y, r, 0, 2 * Math.PI);
    }
    $.stroke();
  }
  t += _t;
  u-=.5;
};
anim();

window.addEventListener('resize', function() {
  c.width = w = window.innerWidth/2;
  c.height = h = window.innerHeight;
}, false);
              
            
!
999px

Console