jweinst1
4/13/2016 - 5:35 PM

draws html canvas scratch

draws html canvas scratch

<!DOCTYPE html>
<html>
<body>


<script>
var canvas = document.createElement('canvas');
canvas.id     = "mycanvas";
canvas.width  = 300;
canvas.height = 300;
canvas.style.zIndex   = 8;
canvas.style.position = "absolute";
canvas.style.border   = "1px solid";
document.body.appendChild(canvas);
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0,0,150,75);
ctx.fillStyle = "#cc33ff"
ctx.fillRect(0,0,5,5)
ctx.fillRect(5,5,5,5)
ctx.fillRect(10,10,5,5)
</script>

</body>
</html>