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

Re: [pygame] font alpha



Rendering the semi-transparent text with the appropriate background 'seems' to make it work again.

#---------------------------------
# Mike's Code modified to use non-black screen
import pygame
import time

pygame.init()
screen = pygame.display.set_mode((640,480), pygame.SRCALPHA)
screen.fill((255,0,255))

myFont = pygame.font.Font(None, 30)

nonTransparent = myFont.render("This text should be fully opaque", 1, (255,255,255))
screen.blit(nonTransparent, (0,0))

myText = 'This text should be somewhat transparent'
semiTransparent = myFont.render(myText, 1, (255,255,255), (255,0,255))
newSurf = pygame.Surface(myFont.size(myText))
newSurf.blit(semiTransparent,(0,0))
newSurf.set_alpha(100)
screen.blit(newSurf, (0,100))

pygame.display.flip()

time.sleep(5)

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