projects
/
naja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
robots repel locks
[naja.git]
/
naja
/
resources
/
mutators.py
diff --git
a/naja/resources/mutators.py
b/naja/resources/mutators.py
index 2a730de5663a3fb39b71e0ea354f02d364781347..382e7c77555edaf0f60e633dab9042c2aa584173 100644
(file)
--- a/
naja/resources/mutators.py
+++ b/
naja/resources/mutators.py
@@
-1,6
+1,8
@@
'''Mutations to apply to images'''
'''Mutations to apply to images'''
-from pygame.transform import rotate, flip
+from pygame.transform import flip, rotate, scale
+
+from naja.constants import EIGHT_BIT_SCALE
class Mutator(object):
class Mutator(object):
@@
-27,6
+29,15
@@
def rotator(angle):
return Mutator(rotate, angle)
return Mutator(rotate, angle)
+def scaler(size):
+ return Mutator(scale, size)
+
+
+def scale_multiplier(image, factor):
+ size = image.get_width() * factor, image.get_height() * factor
+ return scale(image, size)
+
+
# Identity mutator
NULL = Mutator(lambda x: x)
# Identity mutator
NULL = Mutator(lambda x: x)
@@
-37,3
+48,5
@@
R270 = rotator(-90)
FLIP_H = Mutator(flip, True, False)
FLIP_V = Mutator(flip, False, True)
FLIP_H = Mutator(flip, True, False)
FLIP_V = Mutator(flip, False, True)
+
+EIGHT_BIT = Mutator(scale_multiplier, EIGHT_BIT_SCALE)