Last active
December 14, 2015 21:08
-
-
Save syntagmatic/5148544 to your computer and use it in GitHub Desktop.
Canvas Basic Animation
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
<canvas id="painting" width=960 height=500></canvas> | |
<script> | |
canvas = document.getElementById("painting") | |
screen = canvas.getContext("2d") | |
t = 0 | |
function frame() { | |
i = canvas.width | |
while (i -= 10) { | |
j = canvas.height | |
while (j -= 10) { | |
hue = (t * i * j / 3000) % 300 | |
screen.fillStyle = "hsl(" + hue + ",70%,54%)" | |
screen.fillRect(i,j,10,10) | |
} | |
} | |
t++ | |
requestAnimationFrame(frame) | |
} | |
frame() | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment