Skip to content

Instantly share code, notes, and snippets.

@ecounysis
Last active August 29, 2015 14:01
Show Gist options
  • Save ecounysis/5ac128678465edb28ff7 to your computer and use it in GitHub Desktop.
Save ecounysis/5ac128678465edb28ff7 to your computer and use it in GitHub Desktop.
Adds junk
while (document.body.childNodes.length>0) {
document.body.childNodes[0].remove();
}
var can=document.createElement("CANVAS");
can.width=1500;
can.height=1000;
can.id="t1000_500";
document.body.appendChild(can);
var ctx=can.getContext("2d");
var step=30;
var draw = function() {
for(var x=0; x<can.width; x+=step) {
for (var y=0;y<can.height; y+=step) {
var rnd1=Math.floor((Math.random() * 255));
var rnd2=Math.random();
var clr=Math.floor(rnd1);
var num=-1;
ctx.fillStyle = "rgb("+((rnd2<num)?0:clr)+","+((rnd2<num)?200:clr)+","+((rnd2<num)?0:clr)+")";
ctx.fillRect(x,y,step,step);
}
}
};
var on=1;
var to=window.setInterval(draw, 1000/20);
can.onclick = function() {
if (on===1) {
clearInterval(to);
on=0;
}
else {
to=window.setInterval(draw, 1000/20);
on=1
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment