From a5cd82ede3e00203b34b5e99a814aec1b0d1d7f6 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 16 May 2014 00:09:54 +0200 Subject: [PATCH] Add a blend_add transform --- naja/resources/mutators.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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) -- 2.34.1