--- /dev/null
+'''Mutations to apply to images'''
+
+from pygame.transform import rotate, flip
+
+
+class Mutator(object):
+ def __init__(self, func, *args):
+ self._func = func
+ self._args = tuple(args)
+
+ def __call__(self, image):
+ return self._func(image, *self._args)
+
+ def __hash__(self):
+ return hash((self._func, self._args))
+
+ def __eq__(self, other):
+ if not isinstance(other, Mutator):
+ return NotImplemented
+ return (self._func == other._func) and (self._args == other._args)
+
+ def __repr__(self):
+ return '<%s %r>' % (self.__class__.__name__, self._args)
+
+
+def rotator(angle):
+ return Mutator(rotate, angle)
+
+
+# Identity mutator
+NULL = Mutator(lambda x: x)
+
+# Rotation
+R90 = rotator(90)
+R180 = rotator(180)
+R270 = rotator(-90)
+
+FLIP_H = Mutator(flip, True, False)
+FLIP_V = Mutator(flip, False, True)