python - 如何将路径与pycairo合并?
问题描述
我正在使用curve_to用 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()
我想填充对象,但如您所见,我无法全部填充,因为它们是分开的,尚未合并。所以我认为这里最接近的方法是合并它们。
解决方案
关于什么:
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()
我对此进行了测试,它形成了一个填充区域。我不确定它是否正确。
推荐阅读
- python - python中的有限差分方法
- python - 如何使用 sklearn 和 numpy 获得预测的标签?
- c++ - 这个返回元素位置的基于循环的函数有什么问题?
- c# - 无法使用服务帐户通过 SMTP mailkit 和 Gmail API 发送消息
- encryption - base64 解码的字符串给出了奇怪的字符
- php - PHP DateInterval 创建分秒(微秒或毫秒)间隔
- java - 无法从 POST 请求返回数据/响应
- makefile - 为什么Makefile不执行别名语句
- java - 在 exo1.Batiment 类中找不到主方法,请将主方法定义为:public static void main(String[] args) 或 JavaFX 应用程序类
- c - 如何使代码段在运行时可写