Skip to content

Instantly share code, notes, and snippets.

@bencentra
Created June 12, 2017 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bencentra/e2220fad41b83ab6afa5626354342714 to your computer and use it in GitHub Desktop.
Save bencentra/e2220fad41b83ab6afa5626354342714 to your computer and use it in GitHub Desktop.
HTML5 canvas starter file
<!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