summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-14 18:21:13 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-14 18:21:13 +0100
commitb126e6167772e61a831d0547681daff5d5cbccd1 (patch)
tree09c172f8168e03571a8b833d604ffe706ce0a3aa /src
parentload rc (diff)
downloadblueshift-b126e6167772e61a831d0547681daff5d5cbccd1.tar.gz
blueshift-b126e6167772e61a831d0547681daff5d5cbccd1.tar.bz2
blueshift-b126e6167772e61a831d0547681daff5d5cbccd1.tar.xz
fix derp on whitepoint adj
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/__main__.py6
-rw-r--r--src/curve.py26
2 files changed, 21 insertions, 11 deletions
diff --git a/src/__main__.py b/src/__main__.py
index aa9f09e..9d5dd9a 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -18,10 +18,8 @@ from colour import *
from curve import *
-#temperature(6500, series_d, True)
-#divide_by_maximum()
-#temperature(6500, simple_whitepoint, True)
-#clip()
+#temperature(6500, lambda T : divide_by_maximum(series_d(T)), True)
+#temperature(6500, lambda T : clip_whitepoint(simple_whitepoint(T)), True)
#rgb_contrast(1.0, 1.0, 1.0)
#cie_contrast(1.0)
#rgb_brightness(1.0, 1.0, 1.0)
diff --git a/src/curve.py b/src/curve.py
index d3e2a2d..cc3de36 100644
--- a/src/curve.py
+++ b/src/curve.py
@@ -175,15 +175,27 @@ def temperature(temperature, algorithm, linear_rgb = True):
r_curve[i], g_curve[i], b_curve[i] = R, G, B
-def divide_by_maximum():
+def divide_by_maximum(rgb):
'''
- Divide all colour components by the value of the most prominent colour component for each colour
+ Divide all colour components by the value of the most prominent colour component
+
+ @param rgb:[float, float, float] The three colour components
+ @return :[float, float, float] The three colour components divided by the maximum
+ '''
+ m = max([abs(x) for x in rgb])
+ if m != 0:
+ return [x / m for x in rgb]
+ return rgb
+
+
+def clip_whitepoint(rgb):
+ '''
+ Clip all colour components to fit inside [0, 1]
+
+ @param rgb:[float, float, float] The three colour components
+ @return :[float, float, float] The three colour components clipped
'''
- for i in range(i_size):
- m = max([abs(x) for x in (r_curve[i], g_curve[i], b_curve[i])])
- if m != 0:
- for curve in (r_curve, g_curve, b_curve):
- curve[i] /= m
+ return [min(max(0, x), 1) for x in rgb]
def rgb_contrast(r, g, b):