Last active
September 22, 2019 16:57
-
-
Save 64lines/436d0cccc6b3054ed7ef2c4fb3ac7292 to your computer and use it in GitHub Desktop.
[ALGORITHMIC ART] - Heartbeat
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
<body> | |
<canvas id="can" style="height:100%; width: 100%;" | |
style="border:1px solid #c3c3c3;"> | |
</canvas> | |
<script> | |
var canvas = document.getElementById("can"); | |
var ctx = canvas.getContext("2d"); | |
num = 0; | |
colornum = 0; | |
function ran(par) { | |
return Math.floor(Math.random() * par); | |
} | |
function paint() { | |
size = 2 | |
sh = screen.width; | |
color = "#" + colornum.toString(16); | |
for(var i = 0; i < sh*10; i++) { | |
ctx.fillStyle = color; | |
ctx.fillRect(ran(sh), ran(sh), size, size); | |
} | |
num++; | |
colornum += color != '#fff' ? 1 : 0; | |
requestAnimationFrame(paint); | |
} | |
requestAnimationFrame(paint); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment