js+html5实现canvas绘制简单矩形的方法

  作者:bea

本文实例讲述了js+html5实现canvas绘制简单矩形的方法。分享给大家供大家参考。具体实现方法如下: <!DOCTYPE html><html><body><canvas id="myCanvas" width="200" height="100"style="border:1px solid #c3c3c3;">Your browser does not support the HTML5 canvas tag.&l

本文实例讲述了js+html5实现canvas绘制简单矩形的方法。分享给大家供大家参考。具体实现方法如下:




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


希望本文所述对大家的web程序设计有所帮助。




有用  |  无用

猜你喜欢