diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-29 14:29:05 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-29 14:29:05 +0100 |
commit | 25fda69b979be450e1ab8cf3792d1da67410a15d (patch) | |
tree | b3f3e0395acdb27da1b26f89add1de24f3677cac /src/aux.py | |
parent | m (diff) | |
download | blueshift-25fda69b979be450e1ab8cf3792d1da67410a15d.tar.gz blueshift-25fda69b979be450e1ab8cf3792d1da67410a15d.tar.bz2 blueshift-25fda69b979be450e1ab8cf3792d1da67410a15d.tar.xz |
documentation and code reduction
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/aux.py')
-rw-r--r-- | src/aux.py | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -65,8 +65,11 @@ def linearly_interpolate_ramp(r, g, b): # TODO test, demo and document this small_, large_ = len(small) - 1, len(large) - 1 if large_ > small_: for i in range(len(large)): + # Scaling j = i * small_ / large_ + # Floor, weight, ceiling j, w, k = int(j), j % 1, min(int(j) + 1, small_) + # Interpolation large[i] = small[j] * (1 - w) + small[k] * w return (R, G, B) @@ -82,8 +85,11 @@ def functionise(rgb): def fcurve(R_curve, G_curve, B_curve): for curve, cur in curves(R_curve, G_curve, B_curve): for i in range(i_size): + # Nearest neighbour y = int(curve[i] * (len(cur) - 1) + 0.5) + # Truncation to actual neighbour y = min(max(0, y), len(cur) - 1) + # Remapping curve[i] = cur[y] return lambda : fcurve(*rgb) |