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

Re: [pygame] set_clip




thanks for the reply :)

I'll try it out when I get back home.


 --- Pete Shinners <shredwheat@attbi.com> wrote: >
Rene Dudfield wrote:
> > im.set_clip((0, 0, 94, 103))
> > im.blit(im2, (0,0))
> > 
> > im.set_clip((0, 103, 94, 153))
> > im.blit(im3, (0,103))
> > 
> > im, im2, and im3 are the same size (95,154).
> > 
> > Utimately what I need to do is darken part of an
> > image(or lighten the other part).  I was trying to
> > blit the darkened part to the top, and the lighter
> > part to the bottom.
> 
> you've nearly got it. but you'll want to blit each
> image to the same 
> location. change the last blit to this:
> 
>      im.blit(im3, (0,0))
> 
> you can also achieve this effect by not using the
> clipping and passing the 
> third rectangle argument to blit (which controls
> which area of the source 
> image to use). i believe both ways of doing it will
> be the same speed. but 
> just in case you are curious, here is code that
> would do it.
> 
> def darklightblit(dest, litesrc, darksrc, pos,
> splitrows):
>      """assume litesrc and darksrc are the same
> size, and
>       splitrows is between 0 and height"""
>      width, height = litesrc.get_size()
>      r1=dest.blit(litesrc, pos, (0, 0, width,
> height-splitrows))
>      r2=dest.blit(darksrc, pos, (0, splitrows,
> width, splitrows-height))
>      return r1.union(r2) #return dirty rect
> 



__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org