canvas画圆及弧

[code]
/**
* …画圆,半圆,弧形
* @author amyflash.com
*/

(function() {
var can = document.getElementById(“canvas”);
var ctx = can.getContext(“2d”);
ctx.font=”20px Arial”;
ctx.fillText(“画圆,半圆,弧形”,20,20);

ctx.strokeStyle=”#000000″;
ctx.fillStyle=”rgba(255,255,0,0.5)”;//”#FF0000″;
ctx.lineWidth = “5”;
//ctx.fillRect(50,50,200,200);
//ctx.strokeRect(50,50,200,200);

ctx.beginPath();
//ctx.arc(200,200,50,0,Math.PI*2);// 画正圆
//ctx.arc(200,200,50,0,Math.PI);// 画半圆
//画圆弧
ctx.moveTo(0,300);//起点
//ctx.quadraticCurveTo(0,0,300,0);//1个控制点和终点
ctx.bezierCurveTo(0,0,300,0,400,500,25,50);//多个控制点
ctx.fill();
ctx.stroke();

})();
[/code]

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>