为什么aggdraw图像是空白的?



我正在尝试使用Pillow和aggdraw绘制一堆线段。只有一个枕头,我的代码就可以工作了——但是我需要更流畅的线条。我似乎无法用aggdraw画出任何线条。

import aggdraw
from PIL import Image
image = Image.new("RGB", (ROW_SIZE, COL_SIZE), (255,255,255))
#draw = ImageDraw.Draw(image)
draw = aggdraw.Draw(image)
pen = aggdraw.Pen("black", 2)
# Each segment contains two points with x and y coordinates
for segment in segments:
draw.line((segment.point1.x, segment.point1.y, segment.point2.x, segment.point2.y), pen)
image.show()

我还尝试将导入更改为from aggdraw import Draw, Pen并相应地更改用法-但无济于事。

尝试使用:

...
for segment in segments:
draw.line((segment.point1.x, segment.point1.y, segment.point2.x, segment.point2.y), pen)
# Add the following line
draw.flush()
image.show()

最新更新