summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--examples/comprehensive21
-rw-r--r--src/curve.py31
2 files changed, 42 insertions, 10 deletions
diff --git a/examples/comprehensive b/examples/comprehensive
index 8b55ed5..05407b5 100644
--- a/examples/comprehensive
+++ b/examples/comprehensive
@@ -10,7 +10,7 @@
# Geographical coodinates.
-# (KTH computer laboratories in this example.)
+# (KTH building D computer laboratories in this example.)
latitude, longitude = 59.3472, 18.0728
# Custom dayness by time settings.
@@ -137,6 +137,16 @@ if not panicgate:
current_calibration = [calib_get]
+# These are fun curve manipulator settings that lowers the
+# colour resolution. `red_x_resolution` is the number of colours
+# colours there are one encoding axis of the red curve.
+# `red_y_resolution` is how many colours there are on the
+# output axis of the red curve.
+red_x_resolution, red_y_resolution = [i_size], [o_size]
+green_x_resolution, green_y_resolution = [i_size], [o_size]
+blue_x_resolution, blue_y_resolution = [i_size], [o_size]
+
+
# Loads the current monitor calibrations.
m = 0
for i in range(len(current_calibration)):
@@ -265,6 +275,15 @@ def periodically(year, month, day, hour, minute, second, weekday, fade):
# If we only used one parameter, it would be applied to all colour components.
rgb_contrast(contrast_red_, contrast_green_, contrast_blue_)
+ # Apply low colour resolution emulation.
+ rx = red_x_resolution[m % len(red_x_resolution)]
+ ry = red_y_resolution[m % len(red_y_resolution)]
+ gx = green_x_resolution[m % len(green_x_resolution)]
+ gy = green_y_resolution[m % len(green_y_resolution)]
+ bx = blue_x_resolution[m % len(blue_x_resolution)]
+ by = blue_y_resolution[m % len(blue_y_resolution)]
+ lower_resolution(rx, ry, gx, gy, bx, by)
+
# Clip colour curves to fit [0, 1] to avoid errors by complex numbers.
clip()
diff --git a/src/curve.py b/src/curve.py
index 905b7dc..c69bdce 100644
--- a/src/curve.py
+++ b/src/curve.py
@@ -461,18 +461,31 @@ def manipulate(r, g = None, b = None):
curve[i] = f(curve[i])
-# TODO document this elsewhere
-def lower_resolution(x_colours = None, y_colours = None):
+def lower_resolution(rx_colours = None, ry_colours = None, gx_colours = None, gy_colours = None, bx_colours = None, by_colours = None):
'''
Emulates low colour resolution
- @param x_colours:int? The number of colours to emulate on the encoding axis, `i_size` if `None`
- @param y_colours:int? The number of colours to emulate on the output axis, `o_size` if `None`
- '''
- if x_colours is None: x_colours = i_size
- if y_colours is None: y_colours = o_size
- 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):
+ @param rx_colours:int? The number of colours to emulate on the red encoding axis, `i_size` if `None`
+ @param ry_colours:int? The number of colours to emulate on the red output axis, `o_size` if `None`
+ @param gx_colours:int? The number of colours to emulate on the green encoding axis, `rx_colours` of `None`
+ @param gy_colours:int? The number of colours to emulate on the green output axis, `ry_colours` if `None`
+ @param bx_colours:int? The number of colours to emulate on the blue encoding axis, `rx_colours` if `None`
+ @param by_colours:int? The number of colours to emulate on the blue output axis, `rg_colours` if `None`
+ '''
+ if rx_colours is None: rx_colours = i_size
+ if ry_colours is None: ry_colours = o_size
+ if gx_colours is None: gx_colours = rx_colours
+ if gy_colours is None: gy_colours = ry_colours
+ if bx_colours is None: bx_colours = rx_colours
+ if by_colours is None: by_colours = ry_colours
+ r_colours = (rx_colours, ry_colours)
+ g_colours = (gx_colours, gy_colours)
+ b_colours = (bx_colours, by_colours)
+ for i_curve, (x_colours, y_colours) in curves(r_colours, g_colours, b_colours):
+ if (x_colours == i_size) and (y_colours == o_size):
+ continue
+ o_curve = [0] * i_size
+ x_, y_, i_ = x_colours - 1, y_colours - 1, i_size - 1
for i in range(i_size):
x = int(i * x_colours / i_size)
x = int(x * i_ / x_)