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

Re: [pygame] Setting alpha with a blit?



Lì mercoledì, 2004/06/16 alle 20:40, -0700, Jasper Phillips ha scritto:
> 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.

you can load an image with the right alpha and blit it, but with an hex
shape with opaque borders you need to build the right tile image; i.e.,
a suare wuth an hex inside is not enough. 

btw, it would be great if blit supported logical operations (AND, OR,
XOR, NOT) so that you can draw an alpha-255 (opaque) hex on a square
transpartent surface. blit it and build a hex grid with opaque hexes and
then XOR-blit to invert the alpha and gt your hex holes.

sorry for asking for new features already from first-post. :)

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                fog@debian.org
INIT.D Developer                                           fog@initd.org
                             Best friends are often failed lovers. -- Me