projects
/
naja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e4fa85c
)
Add a blend_add transform
author
Neil
<neil@dip.sun.ac.za>
Thu, 15 May 2014 22:09:54 +0000
(
00:09
+0200)
committer
Neil
<neil@dip.sun.ac.za>
Thu, 15 May 2014 22:09:54 +0000
(
00:09
+0200)
naja/resources/mutators.py
patch
|
blob
|
history
diff --git
a/naja/resources/mutators.py
b/naja/resources/mutators.py
index 382e7c77555edaf0f60e633dab9042c2aa584173..36ef2297671d7cc5382d93d6f68430eea163faf3 100644
(file)
--- a/
naja/resources/mutators.py
+++ b/
naja/resources/mutators.py
@@
-4,6
+4,9
@@
from pygame.transform import flip, rotate, scale
from naja.constants import EIGHT_BIT_SCALE
from naja.constants import EIGHT_BIT_SCALE
+from pygame import surface
+import pygame.locals as pgl
+
class Mutator(object):
def __init__(self, func, *args):
class Mutator(object):
def __init__(self, func, *args):
@@
-38,6
+41,20
@@
def scale_multiplier(image, factor):
return scale(image, size)
return scale(image, size)
+def blend_add(image, colour):
+ """Overlay the image with the given colour using BLEND_ADD"""
+ blend = surface.Surface(image.get_size())
+ blend.fill(colour)
+ # We return a copy
+ blended_image = image.copy()
+ blended_image.blit(blend, (0, 0), special_flags=pgl.BLEND_ADD)
+ return blended_image
+
+
+def blender(colour):
+ return Mutator(blend_add, tuple(colour))
+
+
# Identity mutator
NULL = Mutator(lambda x: x)
# Identity mutator
NULL = Mutator(lambda x: x)