Skip to content

Instantly share code, notes, and snippets.

@Mamboleoo
Created August 18, 2014 13:00
Show Gist options
  • Save Mamboleoo/303b29de2a86075267f5 to your computer and use it in GitHub Desktop.
Save Mamboleoo/303b29de2a86075267f5 to your computer and use it in GitHub Desktop.
A Pen by Louis Hoebregts.
<canvas id="canvas"></canvas>
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d'),
ww = window.innerWidth,
wh = window.innerHeight,
g = [ww/2,wh/2],
j = 0;
canvas.width = ww;
canvas.height = wh;
ctx.fillStyle = "black";
ctx.strokeStyle = "rgba(0,0,0,.1)";
var fps = 20;
function draw() {
setTimeout(function() {
requestAnimationFrame(draw);
ctx.translate( g[0],g[1] );
ctx.rotate(Math.PI/30);
ctx.translate( -g[0],-g[1] );
ctx.fillStyle="rgba(255,255,255,.1)";
ctx.strokeStyle="rgba(255,255,255,.1)";
// if(j%2==0)ctx.fillStyle="rgba(255,255,255,.1)";
// else ctx.fillStyle="rgba(0,0,0,.1)";
ctx.beginPath();
ctx.rect(g[0], g[1], j, j);
ctx.stroke();
ctx.closePath();
j+=.5;
}, 1000 / fps);
};
draw();
html,body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: black;
overflow: hidden;
font-family: Helvetica, arial, sans-serif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment