Created
May 28, 2015 05:54
-
-
Save tmcw/9015a58ae877d2d7a5f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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