开发者

How to set color to Rectangle drawn with html5?

I'm learning about Html5.

<html>
<body>
<canvas id="canvas1" width="300" height="200"></canvas>
<script>
 var canvas = document.getElementById("canvas1");
 v开发者_Python百科ar cxt = canvas.getContext("2d");

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

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

How to set color for this Rectangle?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜