Skip to content

Instantly share code, notes, and snippets.

@Mamboleoo
Created September 4, 2014 20:19
Show Gist options
  • Save Mamboleoo/276f46e8a00c837c1a10 to your computer and use it in GitHub Desktop.
Save Mamboleoo/276f46e8a00c837c1a10 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,
j = 0;
initCanvas();
function draw() {
setTimeout(function() {
requestAnimationFrame(draw);
var cos = Math.round(Math.abs(Math.cos(j/200)*255)*100)/100;
ctx.strokeStyle = "rgba("+cos+","+cos+","+cos+",.1)";
ctx.save();
for(var i2=0;i2<3;i2++){
ctx.translate( ww/2,wh/2 );
ctx.rotate(Math.cos(Math.PI*j/400));
ctx.translate( -ww/2,-wh/2 );
for(var i=1;i<5;i++){
ctx.beginPath();
ctx.moveTo(ww*.25, i*wh/5);
ctx.lineTo(ww*.75, i*wh/5);
ctx.stroke();
ctx.closePath();
}
}
ctx.restore();
j++;
}, 42);
};
draw();
window.addEventListener('resize', initCanvas);
function initCanvas(){
ww = window.innerWidth;
wh = window.innerHeight;
canvas.width = ww;
canvas.height = wh;
ctx.strokeStyle="rgba(255,255,255,.1)";
ctx.beginPath();
ctx.arc(ww/2, wh/2, wh*.48, 0, Math.PI*2, false);
ctx.fill();
ctx.clip();
}
html,body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment