summaryrefslogtreecommitdiffstats
path: root/examples/lisp-esque
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-17 21:50:39 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-17 21:50:39 +0100
commitfc08b8c36eab9feba98ddf1bd284b3246f9c4f5e (patch)
tree017ac07372106b23225d15d93e0d119946404888 /examples/lisp-esque
parentupdate makefile to install darkroom example (diff)
downloadblueshift-fc08b8c36eab9feba98ddf1bd284b3246f9c4f5e.tar.gz
blueshift-fc08b8c36eab9feba98ddf1bd284b3246f9c4f5e.tar.bz2
blueshift-fc08b8c36eab9feba98ddf1bd284b3246f9c4f5e.tar.xz
implement _standardise, _manipulate, _linearise and _sigmoid
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--examples/lisp-esque48
1 files changed, 38 insertions, 10 deletions
diff --git a/examples/lisp-esque b/examples/lisp-esque
index 61e1586..b26631f 100644
--- a/examples/lisp-esque
+++ b/examples/lisp-esque
@@ -443,7 +443,7 @@ class Negative:
def __init__(self):
self.monitors = [(False, False, False, False, False, False)]
def __call__(self, monitor, alpha):
- negative(*(self.monitors[monitor][3 if alpha == 0 else 0:][:3]))
+ negative(*(self.monitors[monitor % len(self.monitors)][3 if alpha == 0 else 0:][:3]))
def _negative(mods, args):
'''
@@ -487,7 +487,7 @@ class RGBInvert:
def __init__(self):
self.monitors = [(False, False, False, False, False, False)]
def __call__(self, monitor, alpha):
- rgb_invert(*(self.monitors[monitor][3 if alpha == 0 else 0:][:3]))
+ rgb_invert(*(self.monitors[monitor % len(self.monitors)][3 if alpha == 0 else 0:][:3]))
class CIEInvert:
'''
@@ -496,7 +496,7 @@ class CIEInvert:
def __init__(self):
self.monitors = [(False, False, False, False, False, False)]
def __call__(self, monitor, alpha):
- cie_invert(*(self.monitors[monitor][3 if alpha == 0 else 0:][:3]))
+ cie_invert(*(self.monitors[monitor % len(self.monitors)][3 if alpha == 0 else 0:][:3]))
def _invert(mods, args):
'''
@@ -662,8 +662,15 @@ def _sigmoid(mods, args):
|list<[str, str, str]>> optionally with individual colour curve control;
'nil' for nothing
'''
+ red = 'red' in mods
+ green = 'green' in mods
+ blue = 'blue' in mods
args = evaluate_tree(args, True)
- pass
+ args = [[arg, arg, arg] if isinstance(arg, str) else arg for arg in args]
+ args = [[None if a == 'nil' else float(a) for a in arg] for arg in args]
+ if red or green or blue:
+ args = [[arg[0] if red else None, arg[1] if green else None, arg[2] if blue else None] for arg in args]
+ adjustments.append(lambda monitor : sigmoid(*(args[monitor % len(args)])))
def _limits(mods, args):
@@ -680,7 +687,7 @@ def _limits(mods, args):
|list<list<str>> optionally at each time point (outer)
'''
args = evaluate_tree(args, True)
- pass
+ pass # TODO (limits)
def _linearise(mods, args):
@@ -692,8 +699,15 @@ def _linearise(mods, args):
monitor (or all of them) on whether to convert the curve,
'yes' implied for all monitors if empty
'''
+ red = 'red' in mods
+ green = 'green' in mods
+ blue = 'blue' in mods
args = evaluate_tree(args, True)
- pass
+ args = [[arg, arg, arg] if isinstance(arg, str) else arg for arg in args]
+ args = [[a == 'yes' for a in arg] for arg in args]
+ if red or green or blue:
+ args = [[arg[0] and red, arg[1] and green, arg[2] and blue] for arg in args]
+ adjustments.append(lambda monitor : linearise(*(args[monitor % len(args)])))
def _icc(mods, args):
@@ -706,7 +720,7 @@ def _icc(mods, args):
and optionally (inner) for each monitor.
'''
args = evaluate_tree(args, False)
- pass
+ pass # TODO (icc)
def _manipulate(mods, args):
@@ -719,8 +733,15 @@ def _manipulate(mods, args):
@param args:list<[str, str, str]|str> Function for each monitor (for all if just one specified), and
optionally one per colour curve (red, green and blue)
'''
- args = evaluate_tree(args, True)
- pass
+ red = 'red' in mods
+ green = 'green' in mods
+ blue = 'blue' in mods
+ args = evaluate_tree(args, False)
+ args = [[arg, arg, arg] if isinstance(arg, str) else arg for arg in args]
+ args = [[None if a == 'nil' else eval(a) for a in arg] for arg in args]
+ if red or green or blue:
+ args = [[arg[0] if red else None, arg[1] if green else None, arg[2] if blue else None] for arg in args]
+ adjustments.append(lambda monitor : manipulate(*(args[monitor % len(args)])))
def _standardise(mods, args):
@@ -732,8 +753,15 @@ def _standardise(mods, args):
monitor (or all of them) on whether to convert the curve,
'yes' implied for all monitors if empty
'''
+ red = 'red' in mods
+ green = 'green' in mods
+ blue = 'blue' in mods
args = evaluate_tree(args, True)
- pass
+ args = [[arg, arg, arg] if isinstance(arg, str) else arg for arg in args]
+ args = [[a == 'yes' for a in arg] for arg in args]
+ if red or green or blue:
+ args = [[arg[0] and red, arg[1] and green, arg[2] and blue] for arg in args]
+ adjustments.append(lambda monitor : standardise(*(args[monitor % len(args)])))
# Map function names to functions