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
精彩评论