1

This problem is extended from previous asked question in: Pygame alpha in polygon only

Now i can successfully draw polygon and line with alpha under 2 surface through surface.convert_alpha(). I don't need to set whole surface with alpha (which is a solution searching from online but not suitable in my case). In my understanding, using surface.convert_alpha() allow me to set the alpha in each polygon while using pygame.draw.polygon().

Furthermore, i can also clean existing polygon through the use of alpha locally. If cleaning of polygon is required, i can only draw same polygon at same location with color=(0, 0, 0, 0), so that previous color is covered only at location needed to be clean, this method improve the speed because i don't need to draw whole surface again. I can locally clean pixel at polygon location.

However, when i want to apply same method at Text, it seems not applicable. My example code is:

self.CurInfoCanv = pygame.Surface((1000, 1000), HWSURFACE|DOUBLEBUF|RESIZABLE).convert_alpha()
self.CurInfoFont = pygame.font.SysFont('Comic Sans MS', 30)
Text = self.CurInfoFont.render('TextHere', True, (0, 0, 0, 0))
TextRect = Text.get_rect()
TextRect.topleft = (0, 0)
self.CurInfoCanv.blit(Text, TextRect)
self.Displayer.blit(self.CurInfoCanv, (0, 0))

At self.CurInfoFont.render('TextHere', True, (0, 0, 0, 0)), the color is input with 4th element as alpha, and the Text is still without transparency. Please tell me if there is any mistake or more clever method to do this. Thank you.

HA HA chan
  • 123
  • 1
  • 9

0 Answers0