From 9d10d29b33ba9dbb81a662f2040c666b2c1aac39 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 14 Feb 2014 18:33:59 +0100 Subject: add function manipulate: Manipulate the colour curves using a lambda function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/curve.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/curve.py b/src/curve.py index cc3de36..f88dc87 100644 --- a/src/curve.py +++ b/src/curve.py @@ -281,6 +281,25 @@ def sigmoid(r, g, b): curve[i] = 0; +def manipulate(r, g = None, b = None): + ''' + Manipulate the colour curves using a lambda function + + @param r:(float)→float Lambda function to manipulate the red colour curve + @param g:(float)?→float Lambda function to manipulate the green colour curve, defaults to `r` if `None` + @param b:(float)?→float Lambda function to manipulate the blue colour curve, defaults to `r` if `None` + + The lambda functions thats a colour value and maps it to a new colour value. + For example, if the red value 0.5 is already mapped to 0.25, then if the function + maps 0.25 to 0.5, the red value 0.5 will revert back to being mapped to 0.5. + ''' + if g is None: g = r + if b is None: b = r + for (curve, f) in curves(r, g, b): + for i in range(i_size): + curve[i] = f(curve[i]) + + def clip(): ''' Clip all values below the actual minimum and above actual maximums -- cgit v1.2.3-70-g09d2