import pygame.locals as pgl
+from .constants import COLOURS
+
class Transform(object):
def apply(self, surface):
surface.fill((255, 255, 255, self.alpha), None, pgl.BLEND_RGBA_MULT)
return surface
+
+
+class ColourWedges(Transform):
+ """ Apply colours as wedges. """
+
+ ARGS = ["colours"]
+
+ def apply(self, surface):
+ size = surface.get_width()
+ assert size in (16, 32, 48, 64)
+ fitting_colours = [COLOURS[c] for c in self.colours]
+ ncolour = len(fitting_colours)
+ if ncolour > 3:
+ print "Multicoloured light should not have more than 3 colours"
+ ncolour = 3
+
+ if ncolour == 1:
+ multiply = Multiply(colour=fitting_colours[0])
+ return multiply.apply(surface)
+
+ colour_mult_image = pygame.surface.Surface((size, size))
+ from .loader import loader
+ for i in range(ncolour):
+ sector = loader.load_image(
+ str(size), "light_mask_%d_%d.png" % (ncolour, i + 1),
+ transform=Multiply(colour=fitting_colours[i]))
+ colour_mult_image.blit(sector, (0, 0), None, 0)
+
+ surface.blit(colour_mult_image, (0, 0), None, pgl.BLEND_RGBA_MULT)
+ return surface