box-o-sand/html5/canvas/mdn-tutorial.html
Dan Buch 250bfbdfa0 Goofing around with html5 canvas again
to make sure I'm not missing anything big by mostly using svg (in d3).
2013-02-10 18:16:30 -05:00

34 lines
755 B
HTML

<!DOCTYPE html>
<html>
<head>
<title>MDN Canvas Tutorial</title>
<style type="text/css">
canvas {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="tutorial" width="150" height="150">
hammer down
</canvas>
<script type="text/javascript">
function draw() {
var canvas = document.getElementById('tutorial');
if (!canvas.getContext) {
return;
}
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgb(200, 0, 0)';
ctx.fillRect(10, 10, 55, 50);
ctx.fillStyle = 'rgba(0, 0, 200, 0.5)';
ctx.fillRect(30, 30, 55, 50);
}
window.addEventListener('load', draw, false);
</script>
</body>
</html>