废话不多说,博主很正经的。。。。
一, 绘制圆形时,用到接口beginPath(),arc(),stroke(),
1,beginPath是开始定义路径(没画),
2,arc()是定义你要绘制什么样的圆弧,也没开始画其格式是,context.arc(x, y, radius, startAngle, endAngle, anticlockwise)
3,stroke()是实现你前面两个的定义,吧图绘制出来的。
二:绘制圆形的函数如下;
function drawCircle(){
context.beginPath();
context.arc(canvas.width/2,canvas.height/2,RADIUS,0,Math.PI*2,true);
context.strokeStyle = 'blue';
context.stroke();
}
绘制出来的图形如下:
当我们去掉stroke()接口是,就会发现那个蓝色的圆形不见了。嘿嘿。