html5画简单的圆形代码分享,大家参考使用吧
复制代码代码如下: <!DOCTYPE html><head> <meta charset=utf-8> <title>HTML5画圆形</title> <script src="<a href="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script">http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script</a>> </head> <script> $(document).ready(function(){ var c=document.getElementById("drawbox"); var draw=c.getContext("2d"); //获取2d内容的引用,调用绘图API</p>
<p>draw.fillStyle="red"; //颜色 draw.beginPath(); //从新画 draw.arc(50,50,50,0,Math.PI*2,true); //圆心x坐标|圆心y坐标|直径|始|PI为圆周率,Math.PI*2为画圆|true为时针方向:逆时针,0为顺时针, draw.closePath(); //结束 draw.fill(); }) </script> </body> <canvas id="drawbox" width="500" height="500"></canvas> </body> </html>
效果图
|