X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fresources%2Fmutators.py;h=36ef2297671d7cc5382d93d6f68430eea163faf3;hb=87a82ccb10b6f7b07c48f8e9993243b9592e00b4;hp=382e7c77555edaf0f60e633dab9042c2aa584173;hpb=85f20ca165c1710c96afbc42fa07acb68b6b4c1d;p=naja.git diff --git a/naja/resources/mutators.py b/naja/resources/mutators.py index 382e7c7..36ef229 100644 --- 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 pygame import surface +import pygame.locals as pgl + class Mutator(object): def __init__(self, func, *args): @@ -38,6 +41,20 @@ def scale_multiplier(image, factor): 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)