我正在用 PIL 做一个简单的 pieslice
image = Image.new("RGBA", (256, 128), "#DDD")
draw = ImageDraw.Draw(image, image.mode)
draw.pieslice((0, 0 , 64, 64), 180, 270, fill="white)
del draw
image.save("file.png", "PNG")
如您所见,弧线并不完美。如何用 PIL 制作完美的弧线?
我正在用 PIL 做一个简单的 pieslice
image = Image.new("RGBA", (256, 128), "#DDD")
draw = ImageDraw.Draw(image, image.mode)
draw.pieslice((0, 0 , 64, 64), 180, 270, fill="white)
del draw
image.save("file.png", "PNG")
如您所见,弧线并不完美。如何用 PIL 制作完美的弧线?
在更大的图像上绘制,然后缩小:
N=4
image = Image.new("RGBA", (256*N, 128*N), "#DDD")
draw = ImageDraw.Draw(image, image.mode)
draw.pieslice((0, 0 , 64*N, 64*N), 180, 270, fill="white")
del draw
image = image.resize((256,128)) # using user3479125's correction
image.save("file2.png", "PNG")
unutbu 回答的注意事项:现在 resize() 返回一个调整大小的图像副本。所以不会修改原版。所以这应该是:
N=4
image = Image.new("RGBA", (256*N, 128*N), "#DDD")
draw = ImageDraw.Draw(image, image.mode)
draw.pieslice((0, 0 , 64*N, 64*N), 180, 270, fill="white")
del draw
image = image.resize((256,128))
image.save("file2.png", "PNG")