Created
June 12, 2017 02:45
-
-
Save bencentra/e2220fad41b83ab6afa5626354342714 to your computer and use it in GitHub Desktop.
HTML5 canvas starter file
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Canvas</title> | |
<style> | |
#canvas { | |
border: 1px solid black; | |
} | |
</style> | |
</head> | |
<body> | |
<canvas id="canvas" width="600" height="400"></canvas> | |
<script> | |
var canvas = document.getElementById('canvas'); | |
var context = canvas.getContext('2d'); | |
function erase() { | |
context.fillStyle = '#FFFFFF'; | |
context.fillRect(0, 0, 600, 400); | |
} | |
function draw() { | |
erase(); | |
context.fillStyle = '#FF0000'; | |
context.fillRect(25, 25, 50, 50); | |
window.requestAnimationFrame(draw); | |
} | |
draw(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment