【问题标题】:Draw a circle with different colored section用不同颜色的部分画一个圆圈
【发布时间】:2014-01-27 02:35:24
【问题描述】:

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

但是,这会在圆圈内绘制一条额外的红线,这是我不想要的。我怎样才能摆脱这条线?

【问题讨论】:

    标签: html canvas 2d dart


    【解决方案1】:

    画红线时去掉closePath。

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

    【讨论】:

    • 谢谢!那行得通,也必须删除另一条(黑色)线,然后调整角度,因为有一点白色间隙。
    猜你喜欢
    • 1970-01-01
    • 2013-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-10
    • 2019-04-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多