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

Re: [pygame] Best way to darken an area



On Sat, 2006-10-21 at 14:15 +0200, Farai Aschwanden wrote:
> Anyone of you is experienced in darkening an area from daytime to  
> nighttime?
> 
> - Alpha filter?
> - Setting image pixels to darker value?
> - ???
> 
> I couldn't find anything affecting contrast in Pygame that would help  
> either.
> 
> Any ideas are welcome.

If your graphics use 8bit palette, you can quickly do any sort of
contrast, brightness, hue shifts, etc with pure python code.

You can use the exact same math on a regular 24bit image, but it could
take Python awhile to do fullscreen images. It wouldn't be bad to
precolorize the images at load time, but it may be faster to just load
two images.

If you want to use Numeric and pygame.surfarry you could quickly modify
the colors of any image. Color changes aren't usually hard, but it's
kind of like Python's version of writing a shader, you gotta think a
little different.