[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Unexpect blit behavior when using BLEND_ADD
Also, I guess the docs should be updated to specify which blend
operations the flags do exactly.
On Fri, Apr 18, 2008 at 10:49 AM, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
> Brian Fisher wrote:
>
>
> > On Thu, Apr 17, 2008 at 10:41 AM, Lenard Lindstrom <len-l@xxxxxxxxx
> <mailto:len-l@xxxxxxxxx>> wrote:
> >
> > For alpha surfaces a blend may be useful for doing shadow effects.
> > Such effects require extracting and altering the alpha plane. Want
> > to make a shadow for antialiased text. Extract the alpha and apply
> > to an all black surface. Right now surfarray must be used to do
> > this in a practical way. Otherwise it would have to be done
> > per-pixel with get_at/set_at.
> >
> > I'm curious - how exactly would you expect to be able to extract the alpha
> channel from a font char and apply it to a black surface using the blit
> flags? BLEND_MAX? Is there a technique that would also work for a surface
> with arbitrary color values?
> >
> I was thinking of this:
>
> text = font.render("....", True, some_color)
> alpha = pygame.Surface(text.get_size(), pgyame.SRCALPHA, 32)
> alpha.fill((0, 0, 0, 255))
> alpha.blit(text, (0, 0), None, pygame.BLEND_MIN)
>
> This assumes BLEND_MIN applies to alpha as well. If dA = sA + dA -
> ((sA*dA)/255) then a destination color of (0, 0, 0, 0) will work. Source
> color is irrelevant. It extras alpha from any image.
>
> --
>
> Lenard Lindstrom
> <len-l@xxxxxxxxx>
>
>