Changing colour of a surface without overwriting transparency
You can achieve this by 2 steps. self.original_image contains the filled rectangle with the desired color: self.original_image.fill(self.colour) Generate a completely white rectangle and transparent areas. Blend the rectangle with (self.image) and the blend mode BLEND_MAX (see pygame.Surface.blit): whiteTransparent = pg.Surface(self.image.get_size(), pg.SRCALPHA) whiteTransparent.fill((255, 255, 255, 0)) self.image.blit(whiteTransparent, (0, 0), special_flags=pg.BLEND_MAX) Now the rectangle is completely white, … Read more