summaryrefslogtreecommitdiffstats
path: root/src/curve.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-24 16:10:21 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-24 16:10:21 +0100
commit5c4e823b99ce422285ff7053f5073d6e6dbaacba (patch)
treeb5663150c18807ea708ca1d69153db17f00f1105 /src/curve.py
parentmake lower_resultion's parameters optional (diff)
downloadblueshift-5c4e823b99ce422285ff7053f5073d6e6dbaacba.tar.gz
blueshift-5c4e823b99ce422285ff7053f5073d6e6dbaacba.tar.bz2
blueshift-5c4e823b99ce422285ff7053f5073d6e6dbaacba.tar.xz
improve print_curves with compact parameters + fix lower_resolution
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/curve.py')
-rw-r--r--src/curve.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/curve.py b/src/curve.py
index c559e73..905b7dc 100644
--- a/src/curve.py
+++ b/src/curve.py
@@ -461,7 +461,7 @@ 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
+# TODO document this elsewhere
def lower_resolution(x_colours = None, y_colours = None):
'''
Emulates low colour resolution
@@ -471,14 +471,14 @@ def lower_resolution(x_colours = None, y_colours = None):
'''
if x_colours is None: x_colours = i_size
if y_colours is None: y_colours = o_size
- x_r = i_size / x_colours
- y_r = o_size / y_colours
- for curve in (r_curve, g_curve, b_curve):
+ x_, y_, i_ = x_colours - 1, y_colours - 1, i_size - 1
+ for i_curve, o_curve in curves([0] * i_size, [0] * i_size, [0] * i_size):
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
+ x = int(i * x_colours / i_size)
+ x = int(x * i_ / x_)
+ y = int(i_curve[x] * y_ + 0.5)
+ o_curve[i] = y / y_
+ i_curve[:] = o_curve
def start_over():