2014-01-26 20 views
0

所以我想画一个圆形,用黑色和红色的轮廓填充蓝色。红色部分由look角度决定。 ctx变量保存2d上下文。 相关代码:用不同的彩色部分画一个圆

ctx..lineWidth = 0.5 
    ..fillStyle = "#0000AA" 
    ..strokeStyle = "red"; 

ctx.beginPath(); 
ctx.arc(pos.x, pos.y, radius, look - PI/6, look + PI/6); 
ctx..fill() 
    ..closePath() 
    ..stroke() 
    ..beginPath(); 
ctx.strokeStyle = "black"; 
ctx.arc(pos.x, pos.y, radius, look + PI/6, look - PI/6); 

ctx..fill() 
    ..closePath() 
    ..stroke(); 

但这绘制圆内的附加红线,我不想要的。我怎样才能摆脱这条线?

回答

1

绘制红线时删除closePath。

closePath将绘制一条连接你的红色圆弧的端点(不是你想要的)。

+0

谢谢!这工作,不得不删除其他(黑色)线,然后调整角度,因为有一个白色的差距。 – timedt