<!DOCTYPE html> | |
<script> | |
window.onload = function() { | |
var ctx = document.getElementById('c').getContext('2d'); | |
ctx.fillStyle = 'blue'; // this triggers the lazy creation of the image buffer | |
} | |
</script> | |
<style> | |
canvas { | |
border: solid red; | |
background: green; | |
} | |
</style> | |
<canvas id="c" width="100" height="100"></canvas> |