From f059cb5902e7f98ef988aab040a85404692d99e4 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 19 Mar 2014 03:40:09 +0100 Subject: split ramps_to_function into ramps_to_function and functionise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/aux.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/aux.py b/src/aux.py index ec94549..cc91ef7 100644 --- a/src/aux.py +++ b/src/aux.py @@ -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) -- cgit v1.2.3-70-g09d2