[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] "tint" a surface?



It's not Pygame strictly, but if you're using Pyopengl w/ Pygame, you can
pass such a tint as a "color" param when drawing a textured Quad in
Pyopengl, without needing to monkey with surfaces at all.

-Jasper

> I've been searching around, trying to see if there is a 'best practice"
> way
> of doing this in PyGame.  Havn't found much, time to ask.  I'm used to
> doing
> this in Processing where it's pretty
> easy<http://www.processing.org/reference/tint_.html>,
> so I feel like I may be missing something.  But don't worry, I'm a PyGame
> convert :)
>
> Example:
>
>    - A texture (.png):  donut shape, (donut pixels are white) feathered
>    edges blend into alpha.  Loaded as a Surface.
>    - A predefined Color (say, "orange").
>    - I want to 'tint' my whole Surface based on the Color.  Preferably,
> I'd
>    do this at every loop, it wouldn't be 'baked' into the image.
>
> Currently, I'm kind of hacking around this:
>
>    - Load my featherd donut image.
>    - Make a new "tint" surface based on the donut image resolution.
>    - Fill the "tint" surface with the given color.
>    - Then at each frame:
>    - Blit the tint surface to a copy of my donut surface, with
>       "special_flags=BLEND_RGBA_MULT"
>
> This *does *work.  But seems like a lot of extra surfaces I'm making to
> pull
> it off.  I'd rather see (given the ability)
>
> Surface.tint(someColor)
>
> Which would simply return a new surface tinted with the given color.
> Am I missing something built-in?  Any other ideas?
>
> Thanks
>