summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-14 18:33:59 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-14 18:33:59 +0100
commit9d10d29b33ba9dbb81a662f2040c666b2c1aac39 (patch)
treee4da73a1fa5f4dd6e808fbf5d7c2dc542f479978
parentfix rc exec (diff)
downloadblueshift-9d10d29b33ba9dbb81a662f2040c666b2c1aac39.tar.gz
blueshift-9d10d29b33ba9dbb81a662f2040c666b2c1aac39.tar.bz2
blueshift-9d10d29b33ba9dbb81a662f2040c666b2c1aac39.tar.xz
add function manipulate: Manipulate the colour curves using a lambda function
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/curve.py19
1 files changed, 19 insertions, 0 deletions
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