[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Alpha blending
Pete Shinners wrote:
>
> > you can use the recently added alpha routines in the surfarray
> > module. here is an example of how you could render smooth text
> > with an alpha channel, when set the overall alpha to 50%.
> >
> > >>> import pygame.surfarray as surfarray
> > >>> mytext = myfont.render('Ghosted', 1, (255, 255, 255))
> > >>> alpha = surfarray.pixels_alpha(mytext)
> > >>> alpha /= 2
>
> actually, this may not work as advertised, replace the
> last line with something that i know will work...
>
> >>> divide(alpha, 2, alpha)
>
> > there could be a bug in the display.update() call. it is supposed
> > to fix any rectangles you pass it, but it may be broken. i'll look
> > into this a little more.
>
> i did just check this out more, and the clipping of rects to
> update seems to be working perfectly. if you cannot figure out
> what is failing in your "off-the-edge" blits, try cleaning it
> up and sending it in. everything seems to be working perfectly
> for my little tests.
>
static int screencroprect(GAME_Rect* r, int w, int h)
{
if(r->x >= w || r->y >= h || r->x < 0 || r->y < 0)
return 0;
I think that this should be:
if(r->x >= w || r->y >= h || (r->x + w->w) < 0 || (r->y + r->h) < 0)
Niki Spahiev
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org