[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] "tint" a surface?
- To: pygame-users@xxxxxxxx
- Subject: [pygame] "tint" a surface?
- From: Eric Pavey <warpcat@xxxxxxxxx>
- Date: Sat, 19 Sep 2009 12:44:59 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sat, 19 Sep 2009 15:45:08 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=c7LJiuAKHxOOcXxGffNXkfbs2GB+Dz1+/nTlrHjbkGc=; b=X409gWdPevZJ7IZfsqDslwet+YNYANl3ZX5TbasTcy28ct6ldEe9jt+2ao7A0ERl3s RY1AU5aOv0iagCwpbCxWjyb0GFiZ/XesjwxJSNnmVkXeDGdaa0jBrZFiNGD1UB9q7F+I JmBAl4yeC2CiGlsL5tVkc7OGscspjL8lpZVP4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=pholVeUw11JD1sX4TgOopxZU3rO2KS5pIKc5Y2Hf3q7O1f7XV2PHJk+LNwPOCHvB7O HzsLNPdyEOnPgW0yqMychpsHrMPTFUysrz7y1M2xVO6k9hRlWd0ynitDRb3pfYpr4Llj nvcBP4RAfsUw5gbb8TeA3ZpO+pRTLV86RaSWM=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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, 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