diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-02-24 16:10:21 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-02-24 16:10:21 +0100 |
commit | 5c4e823b99ce422285ff7053f5073d6e6dbaacba (patch) | |
tree | b5663150c18807ea708ca1d69153db17f00f1105 /src | |
parent | make lower_resultion's parameters optional (diff) | |
download | blueshift-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')
-rw-r--r-- | src/curve.py | 16 | ||||
-rw-r--r-- | src/monitor.py | 28 |
2 files changed, 30 insertions, 14 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(): diff --git a/src/monitor.py b/src/monitor.py index 71343a4..67c2c16 100644 --- a/src/monitor.py +++ b/src/monitor.py @@ -178,17 +178,33 @@ def vidmode(*crtcs, screen = 0): pass # Happens on exit by TERM signal -def print_curves(*crtcs, screen = 0): +def print_curves(*crtcs, screen = 0, compact = False): ''' Prints the curves to stdout - @param crtcs:*int Dummy parameter - @param screen:int Dummy parameter + @param crtcs:*int Dummy parameter + @param screen:int Dummy parameter + @param compact:bool Whether to print in compact form ''' (R_curve, G_curve, B_curve) = translate_to_integers() - print(R_curve) - print(G_curve) - print(B_curve) + if compact: + for curve in (R_curve, G_curve, B_curve): + print('[', end = '') + last = None + count = 0 + for i in range(i_size): + if curve[i] == last: + count += 1 + else: + if last is not None: + print('%i {%i}, ' % (last, count), end = '') + last = curve[i] + count = 1 + print('%i {%i}]' % (last, count)) + else: + print(R_curve) + print(G_curve) + print(B_curve) |