html5画布矩形

<!DOCTYPE html>
<html>
  <head>
    <title>绘制矩形</title>
	<script type="text/javascript">
	 function draw() {
       var canvas = document.getElementById("cv"); 
	    //alert(canvas);
		var cxt=canvas.getContext("2d");
		cxt.fillStyle="#FF0000";
		cxt.fillRect(0,0,150,75);
    }   
    </script>
  </head>
  <body onload="draw();"> 
      <canvas id="cv" width="500px" height="400px" style="border:1px solid red">
      </canvas>
  </body>
</html>

猜你喜欢

转载自hylxinlang.iteye.com/blog/1882925