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

Re: [pygame] Inverting colors



Thanks :-) I actually already converted my font to a shapestrip, and I got it working fine now :-) http://pymike.4rensics.org/files/Screenshot-PixelWars-1.png

However pygame SHOULD have a function to invert colors on images. like image.invert()

Cheers

On Wed, Sep 17, 2008 at 9:26 AM, Nicholas Dudfield <ndudfield@xxxxxxxxx> wrote:
The new Color class may have invert but I don't recall.

Well the rgb inverted algorithm is essentially 255 - color

new_red = 255 - old_red
new_green = 255 - old_green
new_blue = 255 - old_blue

So a subtractive blend mode blit may do the trick:

BLEND_RGBA_SUB
BLEND_RGB_SUB

inverted.fill((255,255,255))
inverted.blit(letters, (0,0), None, BLEND_RGB_SUB)

This might work, haven't tested it though...



I'm working on a game, and I made a bitmap font for it. This was quite silly of me; I made each letter a 16x16 image. Well, now I need the letters to invert colors. I was wondering if there's a way to do this in pygame, or if I have to go through all those images (around 40) and make a shapestrip or something?

Thanks,

--
- pymike (http://pymike.4rensics.org/)





--
- pymike (http://pymike.4rensics.org/)