[TriZPUG] PIL draw.ellipse bounding box problem solved

Chris Calloway cbc at unc.edu
Tue Apr 28 21:24:32 CEST 2009


On 4/24/2009 8:20 PM, Joseph Mack NA3T wrote:
> the draw.ellipse function has the syntax
> 
> #(x0,y0) and (x1,y1) are corners of bbox
> ellipse_bbox=(x0,y0,x1,y1)
> 
> draw.ellipse(ellipse_bbox,fill=color)
> 
> I've just spent the last hour or so trying to get this to output a 
> circle. My values of the bbox happened to be top-left and bottom_right. 
> You get no output. The bbox corners have to be lower left and top right.

Sorry, I didn't see this until today.

I ran the following on Winders, virgin Python 2.6, and PIL 1.1.6 with no 
problem and the output I'd expect:

import os
import Image, ImageDraw

os.chdir('\Documents and Settings\cbcoasis\Desktop')

im = Image.new('RGB',(256,256))

draw = ImageDraw.Draw(im)
draw.ellipse((0,0,256,256),outline=(0,255,0),fill=(0,0,255))
del draw

# write to stdout
im.save('pilthing.png', "PNG")

You may be interested in this:

http://stackoverflow.com/questions/326300/python-best-library-for-drawing

You really may be interested in this super low barrier to entry package 
which was the subject of our March meeting, although it is 3D:

http://vpython.org

-- 
Sincerely,

Chris Calloway
http://www.secoora.org
office: 332 Chapman Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599





More information about the TriZPUG mailing list