cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <canvas id="canvas"></canvas>
<div>
  <h4>Click to reset.<br>Scroll to control.</h4>
  <h4>Spirograph used on<br><a href="https://narrowdesign.com">narrowdesign.com</a> </h4>
</div>
            
          
!
            
              body {
  padding: 0;
  margin: 0;
  background: #111;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Droid Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
div {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: start;
  justify-content: space-between;
  cursor: pointer;
}
h4 {
  display: inline-block;
  font-weight: 500;
  background: #111;
  padding: 1rem 1.5rem;
  margin: 1rem;
  line-height: 1.5;
}
a {
  color: red;
}
canvas {
  position: fixed;
  cursor: pointer;
}
            
          
!
            
              var spiraling = false;
var rotation = 0;
var autoInterval;
(function() {
  var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
                              window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
  window.requestAnimationFrame = requestAnimationFrame;

  var winW = window.innerWidth;
  var winH = window.innerHeight;

  var smallScreen = false;
  var spirals;

  var canvas = document.getElementById('canvas');
  var ctx = canvas.getContext('2d');
  var axisX = Math.random();
  var axisY = Math.random();
  var spiralOriginX = winW * axisX
  var spiralOriginY = winW * axisY
  var keydown;

  sizeCanvas();
  var i=0;
  autoInterval = setInterval(drawMbp,1)
  drawMbp();
  window.addEventListener('scroll', function(e) {
    e.preventDefault();
  })
  window.addEventListener('wheel', function(e){
    clearInterval(autoInterval)
    e.preventDefault();
    drawMbp()
    drawMbp()
    drawMbp()
  }
    );
  window.addEventListener('click',function(e){
    axisX = e.pageX/winW
    axisY = e.pageY/winH
    canvas.width = winW;
    canvas.height = winH
    sizeCanvas();
    var i=0;
    clearInterval(autoInterval);
    autoInterval = setInterval(drawMbp,1)
  })
  window.addEventListener('touchstart',function(e){

  })
  window.addEventListener('touchmove',drawMbp);
  window.addEventListener('keydown',function() {
    keydown = true;
    drawMbp()
  });
  window.addEventListener('keyup',function() {
    keydown = false;
  });

  window.addEventListener('resize',function(){
    sizeCanvas()
  })

  function sizeCanvas() {
    winW = window.innerWidth;
    winH = window.innerHeight;
    if (winW < 960) {
      smallScreen = true;
      spirals = ['https://narrowdesign.com/ui/assets/images/spiral-line-mobile.svg','https://narrowdesign.com/ui/assets/images/spiral-line-black-mobile.svg','https://narrowdesign.com/ui/assets/images/spiral-line-magenta-mobile.svg','https://narrowdesign.com/ui/assets/images/spiral-line-cyan-mobile.svg',]
      spiralOriginX = Math.floor((winW) * (1 - axisX))
      spiralOriginY = Math.floor((winW) * axisY)
    } else {
      smallScreen = false;
      spirals = ['https://narrowdesign.com/ui/assets/images/spiral-line.svg','https://narrowdesign.com/ui/assets/images/spiral-line-black.svg','https://narrowdesign.com/ui/assets/images/spiral-line-magenta.svg','https://narrowdesign.com/ui/assets/images/spiral-line-cyan.svg',]
      spiralOriginX = winW * axisX
      spiralOriginY = winH * axisY
    }
    if (winW != canvas.width || winH != canvas.height) {
      canvas.width = winW;
      canvas.height = winH; 
    }
  }

  var spiralRed = new Image;
  spiralRed.src = 'https://narrowdesign.com/ui/assets/images/spiral-line.svg';
  var count = 0;
  function drawMbp(e) {
    if (e) {
      e.preventDefault();
    }
  count++;
    if (count%1440 < 360) {
      spiralRed.src = spirals[0];
    } else if (count%1440 < 720) {
      spiralRed.src = spirals[1];
    } else if (count%1440 < 1080) {
      spiralRed.src = spirals[2];
    } else if (count%1440 < 1440) {
      spiralRed.src = spirals[3];
    }
    requestAnimationFrame(function(){
      ctx.globalAlpha = 1;
      ctx.translate( spiralOriginX, spiralOriginY);
      ctx.rotate(1 + axisY)
      ctx.translate( -spiralOriginX, -spiralOriginY);
      ctx.drawImage(spiralRed, 0,0,winW,winH);
    })
    // }
  }
})();

            
          
!
999px
Loading ..................

Console