--- /dev/null
+""" Image transformations for use with the image loader. """
+
+import pygame.surface
+
+
+class Transform(object):
+
+ ARGS = []
+
+ def __init__(self, **kw):
+ for k in self.ARGS:
+ setattr(self, k, kw.pop(k))
+ assert not kw
+ self.hash = "%s: <%s>" % (
+ self.__class__.__name__,
+ ", ".join("%s=%s" % (k, getattr(self, k)) for k in self.ARGS))
+ return
+
+ def apply(self, surface):
+ raise NotImplementedError("Transforms should implement .apply")
+
+
+class NullTransform(Transform):
+ """ Do nothing. """
+
+ def apply(self, surface):
+ return surface
+
+
+class Overlay(Transform):
+ """ Apply a colour overlay. """
+
+ ARGS = ["colour"]
+
+ def apply(self, surface):
+ over = pygame.surface.Surface(surface.get_size())
+ over = over.convert_alpha()
+ over.fill(self.colour)
+ surface.blit(over, (0, 0), None)
+ return surface