1

我正在尝试使用 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并相应地更改使用 - 无济于事。

4

1 回答 1

0

尝试使用:

...
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()
于 2021-09-18T06:51:27.380 回答