tags:

views:

58

answers:

1

I'm learning about Html5.

<html>
<body>
<canvas id="canvas1" width="300" height="200"></canvas>
<script>
 var canvas = document.getElementById("canvas1");
 var cxt = canvas.getContext("2d");

 context.fillRect(0, 0, 150, 100);

</script>
</body>
</html>

How to set color for this Rectangle?

A: 
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect(0, 0, 150, 100);

fillStyle must be called before fillRect

And if you're not already using it:

https://developer.mozilla.org/en/canvas_tutorial

MooGoo
I haven't seen this. thank you!
Shunter1112