Created
August 23, 2010 17:35
-
-
Save desandro/545932 to your computer and use it in GitHub Desktop.
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 lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>basic canvas</title> | |
<style media="screen"> | |
body { | |
font-family: 'Helvetica Neue', Arial, sans-serif; | |
} | |
canvas { | |
border: 1px solid #CCC; | |
} | |
</style> | |
<script> | |
function init() { | |
var canvas = document.getElementsByTagName('canvas')[0]; | |
if (canvas.getContext) { | |
var | |
ctx = canvas.getContext("2d"), | |
w = canvas.width, // canvas width | |
h = canvas.height // canvas height | |
; | |
// begin canvas code | |
ctx.fillStyle = "rgb(200,0,0)"; | |
ctx.fillRect (10, 10, 50, 50); | |
ctx.fillStyle = "rgba(0, 0, 200, 0.5)"; | |
ctx.beginPath(); | |
ctx.arc (70, 70, 40, 0, Math.PI*2, true); | |
ctx.fill(); | |
ctx.closePath(); | |
} | |
} | |
window.addEventListener('load', init, false); | |
</script> | |
</head> | |
<body> | |
<h1>basic canvas</h1> | |
<canvas width="150" height="150"></canvas> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment