画段弧线 - HTML5 Canvas 作图

6、function DrawArc(Canvas,O,Radius,startAngle, endAngle, anticlockwise)
功能:画段弧线

参数:startAngle:起始角度; endAngle:终止角度;
anticlockwise:是否按照逆时针方向画弧

源代码:

function DrawArc(Canvas,O,Radius,startAngle, endAngle, anticlockwise)
{
//画段弧线,startAngle:起始角度; endAngle:终止角度
//Example: DrawArc(hb,B,50,0,-90,true);//逆时针画弧线
//Example: DrawArc(hb,B,50,0,-90,false);//顺时针画弧线
with (Canvas)
{
arc(O[0],O[1],Radius,startAngle*Math.PI/180, endAngle*Math.PI/180, anticlockwise);
}
}

实例:
Example 1: DrawArc(hb,B,50,0,-90,true);//逆时针画弧线
Example 2: DrawArc(hb,B,50,0,-90,false);//顺时针画弧线
<html>
<script type="text/javascript" src="bigengineer.js"></script>
<body><canvas id="cc" width="2000" height="2000"></canvas>
<script type="text/javascript">
var c=document.getElementById("cc");
var hb=c.getContext("2d");
var B=new Array(150,100);
hb.beginPath();
hb.strokestyle="#000000";
DrawArc(hb,B,90,-135,true);
hb.stroke();
hb.endPath();
</script>
</body>
</html>
Google浏览器浏览的效果如下:

本文节选自我金海龙2010年写的《 HTML5 Canvas 作图函数库2.0版本.pdf 》,

HTML5刚登陆中国大陆的时候,奇缺权威资料,我及时写作,刚一发布,就引起了关注,也成为被盗版的目标,当你们在Google搜索:HTML5 作图 就可以看到我金海龙作品的排名。

这正说明了我的编程实力

再接再厉,做完一个版本、开发完一次,才能觉得不完美。

我最近正在写作《HTML 5 Canvas应用开发者指南》,写完一章节,就发布在我金海龙个人主页上

在我个人博客上只发表其中一些部分段落,写写感想,或者其它的,只要我有时间的话。

posted @ 2012-08-13 09:36  HTML Canvas  阅读(1618)  评论(0编辑  收藏  举报