From: Neil Date: Thu, 15 May 2014 22:09:54 +0000 (+0200) Subject: Add a blend_add transform X-Git-Tag: 0.1~248 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;ds=sidebyside;h=a5cd82ede3e00203b34b5e99a814aec1b0d1d7f6;p=naja.git Add a blend_add transform --- 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)