From 6b021b686cf4edfb40673e64ecda307b4f6262d8 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 22 Feb 2014 13:25:31 +0100 Subject: add (prototype for) lower_resolution just for fun MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/curve.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/curve.py b/src/curve.py index c88b02d..c98f454 100644 --- a/src/curve.py +++ b/src/curve.py @@ -455,6 +455,24 @@ def manipulate(r, g = None, b = None): curve[i] = f(curve[i]) +# TODO document this elsewhere, and make it possible to have non-round x_colours +def lower_resolution(x_colours, y_colours): + ''' + Emulates low colour resolution + + @param x_colours:int The number of colours to emulate on the encoding axis + @param y_colours:int The number of colours to emulate on the output axis + ''' + x_r = i_size / x_colours + y_r = o_size / y_colours + for curve in (r_curve, g_curve, b_curve): + for i in range(i_size): + x = int(x_r * int(i / x_r)) + y = curve[x] * 2 ** 16 + y = int(y_r * int(y / y_r)) + curve[i] = y / 2 ** 16 + + def start_over(): ''' Reverts all colours curves to identity mappings. -- cgit v1.2.3-70-g09d2