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