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

Re: [pygame] Question and suggestions

> I have a question: How can I have non-transparent 
> text/pictures on a transparent surface? I have a 
> transparent popup-dialog, but I want the text rendered on 
> it NOT to be transparent...

you have two options. the easiest might be to just keep
the dialog and text as separate images. you can blit
the dialog background as transparent, then blit the
text on top of that. this might be your easiest bet,
and if the text changes frequently you'll really be
in good shape.

> One suggestion is to be able to have alpha bigger than 256, 
> so if the surface has alpha 150 and the text alpha 405, the 
> text would be rendered with "normal alpha" 255...

no, this can't really work. the maximum alpha value
is 256, so you can't really "cheat" it like this. it'd
be a great solution if it worked :]

the way to do this is by using a "perpixel-alpha". this
means that each pixel gets its own alpha value, instead of
just one constant value for the whole image. the way you
would do it is have the background pixels be transparent,
and then where the text pixels are, be opaque. if the text
never changes, it would be easiest to create a PNG or TGA
image with an alpha channel and set it up in a paint program.
when you load the PNG in pygame it will have the proper 
pixel alpha channels.

> Also, functions to darken/lighten, blend, change contrast 
> and hue on a surface would be cool!

take a look at the surfarray example and tutorial. it has
examples for doing all of these (well, not contrast, but that
would be easy to do). 

pygame mailing list