Labels

Sunday, March 9, 2014

JavaScript: Canvas element with red rectangle

W3Schools has a tutorial on how to draw a canvas with shapes inside it:

<canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
   var c=document.getElementById("myCanvas");
   var ctx=c.getContext("2d");
   ctx.fillStyle="#FF0000";
   ctx.fillRect(0,0,150,75);
</script>


Your browser does not support the HTML5 canvas tag.

The picture is not visible in the Blogger editor.  It only becomes visible when I click preview or publish.

No comments:

Post a Comment