diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-19 03:40:09 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-19 03:40:09 +0100 |
commit | f059cb5902e7f98ef988aab040a85404692d99e4 (patch) | |
tree | 4c60f054d3fc35bf5e60c3a25a27438e7dda1736 /src | |
parent | move translate_to_integers and ramps_to_function to aux.py (diff) | |
download | blueshift-f059cb5902e7f98ef988aab040a85404692d99e4.tar.gz blueshift-f059cb5902e7f98ef988aab040a85404692d99e4.tar.bz2 blueshift-f059cb5902e7f98ef988aab040a85404692d99e4.tar.xz |
split ramps_to_function into ramps_to_function and functionise
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/aux.py | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -46,11 +46,21 @@ def ramps_to_function(r, g, b): r = [y / 65535 for y in r] g = [y / 65535 for y in g] b = [y / 65535 for y in b] + return functionise((r, g, b)) + + +def functionise(rgb): + ''' + Convert a three colour curves to a function that applies those adjustments + + @param rgb:(:float, :float, :float) The colour curves as [0, 1] values + @return :()→void Function to invoke to apply the curves that the parameters [r, g and b] represents + ''' def fcurve(R_curve, G_curve, B_curve): for curve, cur in curves(R_curve, G_curve, B_curve): for i in range(i_size): y = int(curve[i] * (len(cur) - 1) + 0.5) y = min(max(0, y), len(cur) - 1) curve[i] = cur[y] - return lambda : fcurve(r, g, b) + return lambda : fcurve(*rgb) |