More with canvas

This commit is contained in:
Dan Buch 2013-02-10 18:22:52 -05:00
parent 250bfbdfa0
commit 6ae3b13cdc

View File

@ -9,12 +9,15 @@
</style>
</head>
<body>
<canvas id="tutorial" width="150" height="150">
<canvas id="tutorial0" width="150" height="150">
hammer down
</canvas>
<canvas id="tutorial1" width="150" height="150">
rabbit ears
</canvas>
<script type="text/javascript">
function draw() {
var canvas = document.getElementById('tutorial');
function draw0() {
var canvas = document.getElementById('tutorial0');
if (!canvas.getContext) {
return;
}
@ -27,7 +30,22 @@
ctx.fillRect(30, 30, 55, 50);
}
window.addEventListener('load', draw, false);
function draw1() {
var canvas = document.getElementById('tutorial1');
if (!canvas.getContext) {
return;
}
var ctx = canvas.getContext('2d');
ctx.fillRect(25, 25, 100, 100);
ctx.clearRect(45, 45, 60, 60);
ctx.strokeRect(50, 50, 50, 50);
}
window.addEventListener('load', function() {
draw0();
draw1();
}, false);
</script>
</body>
</html>