2013-05-19 104 views
3

我dawing簡單pieslice與PILPython3 PIL(枕頭)draw.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") 

Image

正如你可以看到弧線是不完美的。如何用PIL製作完美的弧線?

+1

它看起來像素化...它看起來更好,如果你把它縮放到更大數量的像素? – SethMMorton

+0

多少錢是合適的? – rkmax

+0

我會說,直到它看起來不錯,你:) – SethMMorton

回答

3

畫一個更大的圖像,然後按比例縮小:

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") 
2

注意事項unutbu的回答是: 現在調整大小()返回圖像的尺寸調整後的副本。所以它不會修改原文。所以這應該是:

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")