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

Re: [pygame] Interface Surfaces



On 4/20/07, Kris Schnee <kschnee@xxxxxxxxxx> wrote:
That's good, but having all these surfaces causes transparency problems.
If I remember correctly: If I want, say, a button with rounded edges
atop a window, then blitting the button -- originally a
transparent-background surface --  onto the window -- which is
translucent -- seems to give me black around the edges. The button is
drawn without transparency when it's drawn onto another surface with
alpha effects, in other words.

As far as I know, Pygame's RGBA to RGBA blit has always done a great
job at preserving alpha (it just has some problems getting the color
right for partially transparent blending). I don't think any other
blit type preserves alpha at all. If you have a sample that throws
transparency away when you think it should be kept, please post the
sample.


The upshot: I'd like to clean up that UI code and make it easier to use.
What do you think of having each widget draw directly to the screen
instead of to the parent widget's surface? Sounds awkward, since they'd
need to know their absolute drawing location. Would it help to use the
Pygame "subsurface" code?

The subsurface stuff sounds like it would be good for what you are doing.

The parent of an object often owns information that determines how
it's children's drawing should be adjusted, while the child usually
owns all the information that determines how to draw the child.
Because of that, having a way for the parent to pass something to the
child that transforms the drawing operations performed by the child
makes a lot of sense.