Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created May 28, 2015 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/9015a58ae877d2d7a5f5 to your computer and use it in GitHub Desktop.
Save tmcw/9015a58ae877d2d7a5f5 to your computer and use it in GitHub Desktop.
<html>
<body><canvas id=swirl width=500 height=500></canvas></body>
<script>
var ctx = document.getElementById('swirl').getContext('2d');
ctx.strokeStyle = '#fff'; ctx.lineWidth = 4; ctx.fillStyle = '#2a2826';
setInterval(function draw() {
function r(op, i, off) {
return 250 + Math[op](i) * (150 + Math.cos(i*8+off) *
Math.pow(Math.PI - Math.abs(Math.abs((+Date.now() / 1000) % (Math.PI*2) - i) - Math.PI), 3));
}
for (var o = 0, j = ctx.fillRect(0, 0, 500, 500); o <= Math.PI; o += Math.PI) {
for (var i = 0, b = ctx.beginPath(); i < (Math.PI * 2) + 0.1; i += 0.02)
ctx.lineTo(r('sin', i, o), r('cos', i, o));
ctx.stroke();
}
}, 1);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment