2024-06-23 20:03:57 发布
网友
如何在图像角上画圆线?在
我可以用
draw.line((x, y, x1, y1), width=4)
但是线条的角不是圆的,而是直的。在
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()
PIL/Pillow中的图形绘制原语是非常基本的,不会像pycairo(tutorial and examples)那样做很好的斜角、米、抗锯齿和圆角。在
也就是说,您可以通过在线条末端绘制圆来模拟线条上的圆角:
相关问题 更多 >
编程相关推荐