I am trying to figure out how to turn the canvas I have created into the background image of the HTML body. Thanks!
<head>
<script type="application/javascript">
function draw() {
var canvas = document.getElementById("canvas");
canvas.style.background = '#D1E0FF';
var context = canvas.getContext("2d");
for (i=0; i<20; i++) {
context.fillStyle = '#FF8533';
context.fillRect (
Math.round(Math.random()*300*100)/100,
Math.round(Math.random()*300*100)/100,
30,
30
);
}
var backgroundURL = canvas.toDataURL();
???
}
</script>
</head>
<body onload="draw();">
<canvas id="canvas" width="300px" height="300px"></canvas>
</body>