added a multiply transform to use on light fittings
[tabakrolletjie.git] / tabakrolletjie / transforms.py
index c5eb05f64e7d85739910eb2f89e1e4f428095070..b748b6e2f545e9a8745f0b869f2c09fde3ddbf4f 100644 (file)
@@ -2,6 +2,8 @@
 
 import pygame.surface
 
+import pygame.locals as pgl
+
 
 class Transform(object):
 
@@ -49,3 +51,16 @@ class Overlay(Transform):
         over.fill(self.colour)
         surface.blit(over, (0, 0), None)
         return surface
+
+
+class Multiply(Transform):
+    """ Apply a colour by multiplying. """
+
+    ARGS = ["colour"]
+
+    def apply(self, surface):
+        mult = pygame.surface.Surface(surface.get_size())
+        mult = mult.convert_alpha()
+        mult.fill(self.colour)
+        surface.blit(mult, (0, 0), None, pgl.BLEND_RGBA_MULT)
+        return surface