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

Re: [pygame] Setting alpha with a blit?



On Thu, 17 Jun 2004, Federico Di Gregorio wrote:

> 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. 

I've tried similar things for other tasks, and hand crafting such a border
is too complex for my tastes.

> 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.

This would be cool too!  I'd settle for just having a blit flag that just
copied RGBA values without combining them with the underlying color.

-Jasper