2017-05-24 22 views
0

这段代码圈:画出离开图像边界

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 

from PIL import Image, ImageDraw 

imo=Image.new("RGB", (85, 64), (204, 204, 204)) 
pos=(10, 64) 
r=8 
draw=ImageDraw.Draw(imo) 
draw.chord((pos[0]-r, pos[1]-r, pos[0]+r, pos[1]+r), 0, 359, (0, 0, 255), (0, 0, 0)) 

for pos in [(32, -1), (85, 32), (32, 64), (-1, 32), (54, 63)]: 
    draw.ellipse((pos[0]-r, pos[1]-r, pos[0]+r, pos[1]+r), (0, 0, 255), (0, 0, 0)) 

pos=(75, 65) 
draw.rectangle((pos[0]-r, pos[1]-r, pos[0]+r, pos[1]+r), (0, 0, 255), (0, 0, 0)) 

imo.save("aa.png", "PNG") 

创建这个(扩大)图像:

 the output of the python code, enlarged

有没有窍门画出的圆圈以这样的方式他们也显示完全填充在图像的底部? 好吧......它对矩形工作正常......但我更喜欢圈子。

+0

该代码似乎为我工作。底部边缘上的圆圈填充一直到底部边缘。就像另一个数据点... – FamousJameous

+0

不适合我。使用python-Pillow-2.8.1-3.6.1.x86_64和python3-Pillow-3.4.2-45.2.x86_64进行测试。你使用什么版本? – dede

+1

我现在已经用枕头版本4.1.1和3.4.2试过了。在Python 3.6和Linux上。两人都工作。 – FamousJameous

回答

0

升级到python-Pillow-2.9.0-6.4.x86_64后,我现在可以获得完全填充的圆圈 - 即使在openSUSE 13.2上也是如此。