[PYTHON IMAGE-SIG] docs for ImagePath? (and a bug)

Anthony Baxter arb@connect.com.au
Fri, 09 May 1997 16:00:42 +1000


I've been reading the source for path.c to try to figure out the ImagePath
module. As far as I can tell, ImagePath does the following. Can someone
(Hi Fredrik!) confirm or deny these bits?

ImagePath.Path(sequence)
    Returns a Path object. This behaves like a sequence of x,y tuples, and
    can be passed to ImageDraw.Draw methods and the like. Actually, no, it
    doesn't. It supports the len and getitem methods, but everything else
    is a null pointer, and causes Python to seg fault if called. 

BUG This is a bug - if you're going to pretend to be a sequence, you should
    support all methods of the sequence. (even if you just raise a TypeError)

    It can be passed a sequence of (x,y) tuples, a sequence of numbers
    (which are interpreted as (x0,y0,x1,y1,x2,y2,....), or another Path 
    object.

Path objects have the following methods:

compact([dist])
    Simple-minded method to shorten path.  A point is removed if
    the city block distance to the previous point is less than the
    given distance. "city block distance"? dist defaults to '2.0'

getbbox()
    return the bounding box of all points in the path.

map(fn)
    apply function fn to each (x,y) element of the path. fn will be called
    as fn(x,y). Don't try the real funky map() tricks - it's not really the
    same as map(). :)

(why doesn't it have filter and reduce?)

tolist()
    return the path as a list of xy tuples.

transform((a,b,c,d,e,f)[,wrap])
    perform an affine transform on each point in the path. 
    (x,y) = (a*x+b*y+c, d*x+e*y+f)
    if wrap is passed as an arg, wrap y coordinate points at 'wrap'.
    

_______________
IMAGE-SIG - SIG on Image Processing with Python

send messages to: image-sig@python.org
administrivia to: image-sig-request@python.org
_______________