1.1 --- a/optimiser.py Sat Oct 03 19:53:13 2015 +0200
1.2 +++ b/optimiser.py Sat Oct 03 21:48:07 2015 +0200
1.3 @@ -50,15 +50,20 @@
1.4
1.5 # Find the dominant complementary pair.
1.6
1.7 - d.sort(reverse=True)
1.8 - found = set()
1.9 + found = {}
1.10 +
1.11 for f, value in d:
1.12 - value, complement = complements(value)
1.13 - if value in found or complement in found:
1.14 - found = [value, complement]
1.15 - break
1.16 + l = list(complements(value))
1.17 + l.sort()
1.18 + t = tuple(l)
1.19 + if not found.has_key(t):
1.20 + found[t] = f
1.21 else:
1.22 - found.add(value)
1.23 + found[t] += f
1.24 +
1.25 + pairs = [(f, t) for t, f in found.items()]
1.26 + pairs.sort(reverse=True)
1.27 + found = pairs[0][1]
1.28
1.29 # Remove the dominant primary (or black) from the list of colours.
1.30
1.31 @@ -210,12 +215,6 @@
1.32 most = [value for n, value in c[:4]]
1.33 least = [value for n, value in c[4:]]
1.34
1.35 - #if least:
1.36 - # if (0, 0, 0) in least[:2]:
1.37 - # replace((0, 0, 0), most)
1.38 - # if (255, 255, 255) in least[:2]:
1.39 - # replace((255, 255, 255), most)
1.40 -
1.41 for x in range(0, width):
1.42 rgb = im.getpixel((x, y))
1.43