[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] set_clip



On Wed, 15 Nov 2000, Pete Shinners wrote:

>> Another thing, how are Rects supposed to be created? I apparently need to
>> send a Rect to Surface.set_clip()? I tried the obvious Rect(x,y,w,h), but
>> that didn't work. Passing a tuple [x,y,w,h] to set_clip() gave me a SDL
>> segmentation fault.
>
>i didn't run into problems with set_clip(), i'm curious on how you
>are using it. here is some interactive playtime i did.

I didn't understand Rects, so I tried passing the raw coordinates. Looking
at the code below:

> >>> s.set_clip((20, 20, 60, 60))

I never used the inner parenthesis. This apparently was accepted by
Python, but killed SDL. I'll try the approach above, and I'm sure that
will work. I'm still not used to the Python way of putting extra () around
parameters to group them into sequences.



>in my "new" version, all are acceptable calls to set_clip
>
>pos = 20, 10
>size = 120, 110
>surf.set_clip(pos, size)
>surf.set_clip(pos + size)
>surf.set_clip(20, 10, 120, 110)
>r = rect(pos, size)
>surf.set_clip(r)
>surf.set_clip((20, 10), r[2:])

Powerful. I tried the one solution which apparently didn't work with
Python 2.0... :-) 

Thanks for the help, I'm off now to test my new knowledge.

--------------------+--------------------------------------------------------
Jan 'Chakie' Ekholm |     Balrog New Media    http://www.balrog.fi/
   Linux Inside     | I'm the blue screen of death, nobody hears your screams

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org