diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-26 09:01:15 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-26 09:04:45 +0100 |
commit | ce72fb847f8eec07739112b8effef0db4e8cfd21 (patch) | |
tree | 5958d61c67e0acbfad62390c0e86cf886139b4c8 | |
parent | m + add cie_temperature (diff) | |
download | blueshift-ce72fb847f8eec07739112b8effef0db4e8cfd21.tar.gz blueshift-ce72fb847f8eec07739112b8effef0db4e8cfd21.tar.bz2 blueshift-ce72fb847f8eec07739112b8effef0db4e8cfd21.tar.xz |
update adhoc mode with cie_temperature
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | TODO | 2 | ||||
-rwxr-xr-x | src/__main__.py | 8 | ||||
-rw-r--r-- | src/adhoc.py | 24 |
3 files changed, 23 insertions, 11 deletions
@@ -5,7 +5,7 @@ High priority: Medium priority: Add a section in manual for information on which order to apply settings and how it affects the result. - Test and demo cie_temperature + Demo cie_temperature Low priority: Raw ramp applying functions with precalcuated interpolation, polynomial diff --git a/src/__main__.py b/src/__main__.py index e5e6d9b..dec8d2f 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -355,6 +355,7 @@ parser.add_argumented(['-g', '--gamma'], 0, 'RGB|R:G:B', 'Set gamma correction' parser.add_argumented(['-b', '--brightness'], 0, 'RGB|R:G:B', 'Set brightness using sRGB' + dn) parser.add_argumented(['+b', '++brightness'], 0, 'Y', 'Set brightness using CIE xyY' + dn) parser.add_argumented(['-t', '--temperature'], 0, 'TEMP', 'Set colour temperature' + dn) +parser.add_argumented(['+t', '++temperature'], 0, 'TEMP', 'Set colour temperature using CIE xyY' + dn) parser.add_argumented(['-l', '--location'], 0, 'LAT:LON', 'Select your GPS location\n' 'Measured in degrees, negative for south or west') parser.add_argumentless(['-r', '--reset'], 0, 'Reset to default settings') @@ -393,11 +394,12 @@ location = a(parser.opts['--location']) gammas = parser.opts['--gamma'] rgb_brightnesses = parser.opts['--brightness'] cie_brightnesses = parser.opts['++brightness'] -temperatures = parser.opts['--temperature'] +rgb_temperatures = parser.opts['--temperature'] +cie_temperatures = parser.opts['++temperature'] output = parser.opts['--output'] if output is None: output = [] -used_adhoc = any([doreset, location, gammas, rgb_brightnesses, cie_brightnesses, temperatures, output]) +used_adhoc = any([doreset, location, gammas, rgb_brightnesses, cie_brightnesses, rgb_temperatures, cie_temperatures, output]) ## Verify option correctness a = lambda opt : 0 if parser.opts[opt] is None else len(parser.opts[opt]) @@ -413,7 +415,7 @@ for opt in ('--gamma', '--brightness', '++brightness', '--temperature'): g, l = globals(), dict(locals()) for key in l: g[key] = l[key] -settings = [gammas, rgb_brightnesses, cie_brightnesses, temperatures] +settings = [gammas, rgb_brightnesses, cie_brightnesses, rgb_temperatures, cie_temperatures] if (config_file is None) and any([doreset, location] + settings): ## Use one time configurations code, pathname = None, None diff --git a/src/adhoc.py b/src/adhoc.py index 19ece22..b90418e 100644 --- a/src/adhoc.py +++ b/src/adhoc.py @@ -34,16 +34,24 @@ d = lambda a, default : [default, default] if a is None else (a * 2 if len(a) == gammas = d(gammas, "1:1:1") rgb_brightnesses = d(rgb_brightnesses, "1") cie_brightnesses = d(cie_brightnesses, "1") -if temperatures is None: - temperatures = ['3700', '6500'] -elif len(temperatures) == 1: - temperatures *= 2 +if (rgb_temperatures is None) and (cie_temperatures is None): + rgb_temperatures = ['3700', '6500'] + cie_temperatures = ['6500', '6500'] +else: + if rgb_temperatures is None: + rgb_temperatures = ['6500', '6500'] + elif len(rgb_temperatures) == 1: + rgb_temperatures *= 2 + if cie_temperatures is None: + cie_temperatures = ['6500', '6500'] + elif len(cie_temperatures) == 1: + cie_temperatures *= 2 ## Parse string arrays into floating point matrices -settings = [gammas, rgb_brightnesses, cie_brightnesses, temperatures, [location]] +settings = [gammas, rgb_brightnesses, cie_brightnesses, rgb_temperatures, cie_temperatures, [location]] s = lambda f, v : f(v) if v is not None else None settings = [s(lambda c : [s(lambda x : [float(y) for y in x.split(':')], x) for x in c], c) for c in settings] -[gammas, rgb_brightnesses, cie_brightnesses, temperatures, location] = settings +[gammas, rgb_brightnesses, cie_brightnesses, rgb_temperatures, cie_temperatures, location] = settings location = None if location is None else location[0] ## Select method for calculating to what degree the adjustments should be applied @@ -86,7 +94,9 @@ def apply(dayness, pureness): start_over() interpol_ = lambda d, p, a, r : d * r + (p[0] * a + p[1] * (1 - a)) * (1 - r) interpol = lambda d, p : [interpol_(d, [p[0][i], p[1][i]], dayness, pureness) for i in range(len(p[0]))] - temperature(*interpol(6500, temperatures), algorithm = lambda t : divide_by_maximum(cmf_10deg(t))) + temperature_algorithm = lambda t : clip_whitepoint(divide_by_maximum(cmf_10deg(t))) + rgb_temperature(*interpol(6500, rgb_temperatures), algorithm = temperature_algorithm) + cie_temperature(*interpol(6500, cie_temperatures), algorithm = temperature_algorithm) rgb_brightness(*interpol(1, rgb_brightnesses)) cie_brightness(*interpol(1, cie_brightnesses)) clip() |