# HG changeset patch # User Paul Boddie # Date 1444483512 -7200 # Node ID 7d63ab284ab8ae3019392227a8e4a040dac7516d # Parent 9373e63a5e483bb238184823092d537cfc8d49bf# Parent 7a5a1508ef30f51099b49857cce06fed3f9badc7 Merged tidying changes. diff -r 9373e63a5e48 -r 7d63ab284ab8 optimiser.py --- a/optimiser.py Sat Oct 10 15:18:14 2015 +0200 +++ b/optimiser.py Sat Oct 10 15:25:12 2015 +0200 @@ -25,7 +25,6 @@ import EXIF import PIL.Image import itertools -import math import sys corners = [ @@ -41,11 +40,6 @@ def clip(v): return int(within(v, 0, 255)) -def distance(rgb1, rgb2): - r1, g1, b1 = rgb1 - r2, g2, b2 = rgb2 - return math.sqrt(pow(r1 - r2, 2) + pow(g1 - g2, 2) + pow(b1 - b2, 2)) - def restore(srgb): r, g, b = srgb return int(r * 255.0), int(g * 255.0), int(b * 255.0) @@ -70,9 +64,9 @@ # Get the colour with components scaled from 0 to 1, plus the inverted # component values. - rgb = scale(rgb) - rgbi = invert(rgb) - pairs = zip(rgbi, rgb) + srgb = scale(rgb) + rgbi = invert(srgb) + pairs = zip(rgbi, srgb) # For each corner of the colour cube (primary and secondary colours plus # black and white), calculate the corner value's contribution to the @@ -124,7 +118,7 @@ out[0] += v * rgb[0] out[1] += v * rgb[1] out[2] += v * rgb[2] - return out + return tuple(map(int, out)) def pattern(rgb, chosen=None):