1.1 --- a/optimiser.py Fri Oct 09 00:34:32 2015 +0200
1.2 +++ b/optimiser.py Fri Oct 09 00:40:59 2015 +0200
1.3 @@ -62,39 +62,33 @@
1.4
1.5 # Colour distribution functions.
1.6
1.7 -cache = {}
1.8 -
1.9 def combination(rgb):
1.10
1.11 "Return the colour distribution for 'rgb'."
1.12
1.13 - if not cache.has_key(rgb):
1.14 -
1.15 - # Get the colour with components scaled from 0 to 1, plus the inverted
1.16 - # component values.
1.17 + # Get the colour with components scaled from 0 to 1, plus the inverted
1.18 + # component values.
1.19
1.20 - rgb = extra(scale(rgb))
1.21 - rgbi = invert(rgb)
1.22 - pairs = zip(rgbi, rgb)
1.23 + rgb = extra(scale(rgb))
1.24 + rgbi = invert(rgb)
1.25 + pairs = zip(rgbi, rgb)
1.26
1.27 - # For each corner of the colour cube (primary and secondary colours plus
1.28 - # black and white), calculate the corner value's contribution to the
1.29 - # input colour.
1.30 + # For each corner of the colour cube (primary and secondary colours plus
1.31 + # black and white), calculate the corner value's contribution to the
1.32 + # input colour.
1.33
1.34 - d = []
1.35 - for corner in corners:
1.36 - rs, gs, bs = scale(corner)
1.37 -
1.38 - # Obtain inverted channel values where corner channels are low;
1.39 - # obtain original channel values where corner channels are high.
1.40 + d = []
1.41 + for corner in corners:
1.42 + rs, gs, bs = scale(corner)
1.43
1.44 - d.append((pairs[0][int(rs)] * pairs[1][int(gs)] * pairs[2][int(bs)], corner))
1.45 -
1.46 - # Balance the corner contributions.
1.47 + # Obtain inverted channel values where corner channels are low;
1.48 + # obtain original channel values where corner channels are high.
1.49
1.50 - cache[rgb] = balance(d)
1.51 + d.append((pairs[0][int(rs)] * pairs[1][int(gs)] * pairs[2][int(bs)], corner))
1.52
1.53 - return cache[rgb]
1.54 + # Balance the corner contributions.
1.55 +
1.56 + return balance(d)
1.57
1.58 def complements(rgb):
1.59