如何将path与pycairo合并?

2024-03-29 12:40:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用pycairo绘制曲线,代码如下:

ctx.move_to(0.4,0.8)
ctx.curve_to(0.3,0.4 ,0.4,0.4 ,0.4,0.4)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width(0.001)
ctx.fill()

ctx.move_to(0.4,0.8)
ctx.line_to(0.5,0.8)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width(0.001)
ctx.stroke()


ctx.move_to(0.5,0.8)
ctx.curve_to(0.6,0.4 ,0.5,0.4 ,0.5,0.4)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width(0.001)
ctx.fill()

ctx.move_to(0.4,0.4)
ctx.line_to(0.5,0.4)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width(0.001)
ctx.stroke()

enter image description here

我想填充对象,但正如你所见,我不能填充所有对象,因为它们是分开的,还没有合并。所以我认为最接近的方法是合并它们。你知道吗


Tags: to对象sourcemovestrokeline绘制rgb
1条回答
网友
1楼 · 发布于 2024-03-29 12:40:33

关于:

    ctx.set_source_rgb(0,0,0)
    ctx.set_line_width(0.001)

    ctx.move_to(0.5,0.8)
    ctx.line_to(0.4,0.8)
    ctx.curve_to(0.3,0.4 ,0.4,0.4 ,0.4,0.4)

    ctx.move_to(0.4,0.4)
    ctx.line_to(0.5,0.8)
    ctx.curve_to(0.6,0.4 ,0.5,0.4 ,0.5,0.4)

    ctx.fill()

我测试了它,它形成了一个填充区域。我不确定这是否正确。你知道吗

相关问题 更多 >