Last active
August 29, 2015 14:09
-
-
Save bouk/3278d03657084cee453f to your computer and use it in GitHub Desktop.
html
This file contains hidden or 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> | |
<head> | |
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> | |
<style>*{margin:0;padding:0;}</style> | |
</head> | |
<body> | |
<canvas id="screen" width=1920 height=1080></canvas> | |
<script> | |
var step = 0; | |
var width=1920; | |
var height=1080; | |
var blocksize=24; | |
function render(x, y, t) { | |
return [x^y*(t%30), (x%8)^(y%16), parseInt(Math.random()*128), 255] | |
} | |
function drawScreen() { | |
step += 1 | |
var c=document.getElementById("screen"); | |
var ctx=c.getContext("2d"); | |
for (x = 0; x < width/blocksize; x++) { | |
for (y = 0; y < height/blocksize; y++) { | |
posX = x * blocksize; | |
posY = y * blocksize; | |
color = render(x, y, step); | |
ctx.fillStyle = "rgba(" + color[0] + "," + color[1] + "," + color[2] + "," + color[3] + ")"; | |
ctx.fillRect(posX, posY, blocksize, blocksize); | |
} | |
} | |
} | |
setInterval(drawScreen, 33); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment