最佳答案
PIL/Pillow 中的图形绘制基元非常基本,不会像 pycairo 这样的专用图形绘制包那样做漂亮的斜角、米、抗锯齿和圆角边缘。 (tutorial and examples)。
话虽如此,您可以通过在线端绘制圆圈来模拟在线上的圆边:
from PIL import Image, ImageDraw
im = Image.new("RGB", (640, 240))
dr = ImageDraw.Draw(im)
def circle(draw, center, radius, fill):
dr.ellipse((center[0] - radius + 1, center[1] - radius + 1, center[0] + radius - 1, center[1] + radius - 1), fill=fill, outline=None)
W = 40
COLOR = (255, 255, 255)
coords = (40, 40, 600, 200)
dr.line(coords, width=W, fill=COLOR)
circle(dr, (coords[0], coords[1]), W / 2, COLOR)
circle(dr, (coords[2], coords[3]), W / 2, COLOR)
im.show()
关于python - 在ImageDraw python中绘制圆角线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33076575/