Mike Lawrence wrote:
Hi all,
Apologies for the seemingly newb help request but I can't seem to
figure out how to vary the alpha value of rendered font surfaces.
Here are my attempts thusfar:
import pygame
pygame.init()
screen = pygame.display.set_mode((640,480), pygame.SRCALPHA)
screen.fill((0,0,0))
myFont = pygame.font.Font(None, 30)
nonTransparent = myFont.render("This text should be fully opaque",
1, (255,255,255))
screen.blit(nonTransparent, (0,0))
semiTransparent = myFont.render("This text should be somewhat
transparent", 1, (255,255,255))
semiTransparent.set_alpha(100)
screen.blit(semiTransparent, (0,100))
pygame.display.flip()
#When I flip, both messages are the same color, indicating that
the transparency on the second failed
I don't think that fonts are rendered with surface alpha to start.
does set_alpha apply surface alpha if they don't have it already?
Maybe try convert_alpha first?
It's possible that since you're aliasing the fonts they might be
using per-pixel alpha which might conflict with surface alpha.
Just some suggestions, I've never tried this.
-Luke
--
Mike Lawrence
Graduate Student, Department of Psychology, Dalhousie University
Website: http://memetic.ca
Public calendar: http://icalx.com/public/informavore/Public
"The road to wisdom? Well, it's plain and simple to express:
Err and err and err again, but less and less and less."
- Piet Hein