, ((6, 6), ThemeColor(100, 1, 1, 3500)) ] ) describe "applying a range": it "adds one color if length is 1": color = ThemeColor(0, 1, 1, 3500) color2 = ThemeColor(100, 1, 1, 3500) colors = ZoneColors() colors.apply_to_range(color, color2, 1) self.assertEqual(colors._colors, [color]) it "adds two colors if length is 2 where second color is averaged": color = ThemeColor(0, 1, 1, 3500) color2 = ThemeColor(100, 1, 1, 3500) second_color = ThemeColor.average([color2.limit_distance_to(color), color]) colors = ZoneColors() colors.apply_to_range(color, color2, 2) self.assertEqual(colors._colors, [color, second_color]) it "applies a gradient for length greater than two": color = ThemeColor(0, 1, 1, 3500) color2 = ThemeColor(100, 1, 1, 3500) colors = ZoneColors() colors.apply_to_range(color, color2, 8) hues = [float("{:.3f}".format(c.hue)) for c in colors._colors] self.assertEqual(hues, [0.0, 12.5, 25.0, 37.5, 50.0, 62.5, 75.0, 87.5]) describe "applying a theme":
def assertNewHue(self, hue1, hue2, expected_hue): color = ThemeColor(hue1, 0.1, 0.6, 3500) color2 = ThemeColor(hue2, 0.2, 0.5, 4500) limited = color.limit_distance_to(color2) self.assertEqual(limited, ThemeColor(expected_hue, 0.1, 0.6, 3500))