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

Re: [pygame] Setting alpha with a blit?



On Wed, 16 Jun 2004, Jasper Phillips wrote:

>
>I have a surface to which I want to add hex shaped transparent holes, with
>the aim of creating a "frame" that I can blit onto a hex map to mask
>anything outside the hexes.
>
>As a first attempt I've just iterated through all the pixels and set them
>transparent as appropriate.  This is a bit slow however, and what I'd really
>like is to somehow "blit" transparency onto a surface, setting the
>underlying pixel values rather than modifying them.
>
>Is there some api or trick for doing this?

We have used colorkeying for this. It basically means setting all the
"extra" stuff with some color you won't be using, such as #000000, and
then just use set_colorkey() for that color. Easy and fast enough.

-- 

             Gravity is a habit that is hard to shake off.
                                              -- Terry Pratchett, Small Gods