diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-02-22 13:25:31 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-02-22 13:25:31 +0100 |
commit | 6b021b686cf4edfb40673e64ecda307b4f6262d8 (patch) | |
tree | 0f9d29e6fb9baa3b99be85f7635a98db601b21bd /src/curve.py | |
parent | m (diff) | |
download | blueshift-6b021b686cf4edfb40673e64ecda307b4f6262d8.tar.gz blueshift-6b021b686cf4edfb40673e64ecda307b4f6262d8.tar.bz2 blueshift-6b021b686cf4edfb40673e64ecda307b4f6262d8.tar.xz |
add (prototype for) lower_resolution just for fun
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/curve.py')
-rw-r--r-- | src/curve.py | 18 |
1 files changed, 18 insertions, 0 deletions
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. |