Html 用不同颜色的剖面画一个圆

Html 用不同颜色的剖面画一个圆,html,canvas,2d,dart,Html,Canvas,2d,Dart,所以我想画一个圆圈,用黑色和红色的轮廓填充蓝色。红色部分由外观角度决定。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(

所以我想画一个圆圈,用黑色和红色的轮廓填充蓝色。红色部分由
外观
角度决定。
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();

然而,这在圆圈内画了一条额外的红线,这是我不想要的。如何删除这条线?

在绘制红线时删除闭合路径


closePath将画一条线连接红色圆弧的端点(不是您想要的)。

谢谢!这是可行的,必须移除另一条(黑色)线,然后调整角度,因为有一个小的白色间隙。