def test_hue(self): """Test `hue`.""" c = Color('color(--lchuv 90% 50 120 / 1)') self.assertEqual(c.hue, 120) c.hue = 110 self.assertEqual(c.hue, 110)
def test_hue(self): """Test `hue`.""" c = Color('color(--jzczhz 0.22 0.5 270 / 1)') self.assertEqual(c.hue, 270) c.hue = 0.1 self.assertEqual(c.hue, 0.1)
def test_hue(self): """Test `hue`.""" c = Color('color(--okhsl 120 50% 90% / 1)') self.assertEqual(c.hue, 120) c.hue = 110 self.assertEqual(c.hue, 110)
def get_color_map_square(self): """Get a square variant of the color map.""" global color_map global color_map_size global line_height global default_border global color_scale global last_saturation s = self.color.convert("hsl").saturation # Only update if the last time we rendered we changed # something that would require a new render. if (color_map is None or s != last_saturation or self.graphic_size != color_map_size or self.graphic_scale != color_scale or self.line_height != line_height or self.default_border != default_border): color_map_size = self.graphic_size color_scale = self.graphic_scale line_height = self.line_height default_border = self.default_border html_colors = [] # Generate the colors with each row being dark than the last. # Each column will progress through hues. color = Color("hsl(0 {}% 90%)".format(s), filters=util.SRGB_SPACES) hfac = 24.0 lfac = 8.0 check_size = self.check_size(self.height) for y in range(0, 11): html_colors.append([self.get_spacer(width=5)]) for x in range(0, 15): value = color.convert("srgb").to_string(**HEX) kwargs = { "border_size": BORDER_SIZE, "height": self.height, "width": self.width, "check_size": check_size } if y == 0 and x == 0: border_map = colorbox.TOP | colorbox.LEFT elif y == 0 and x == 14: border_map = colorbox.TOP | colorbox.RIGHT elif y == 0: border_map = colorbox.TOP elif y == 10 and x == 0: border_map = colorbox.BOTTOM | colorbox.LEFT elif y == 10 and x == 14: border_map = colorbox.BOTTOM | colorbox.RIGHT elif y == 10: border_map = colorbox.BOTTOM elif x == 0: border_map = colorbox.LEFT elif x == 14: border_map = colorbox.RIGHT else: border_map = 0 kwargs["border_map"] = border_map html_colors[-1].append('<a href="{}">{}</a>'.format( color.to_string(**COLOR_FULL_PREC), mdpopups.color_box([value], self.default_border, **kwargs))) color.hue = color.hue + hfac color.hue = 0.0 color.lightness = color.lightness - lfac # Generate a grayscale bar. lfac = 10.0 color = Color('hsl(0 0% 100%)', filters=util.SRGB_SPACES) check_size = self.check_size(self.height) for y in range(0, 11): value = color.convert("srgb").to_string(**HEX) kwargs = { "border_size": BORDER_SIZE, "height": self.height, "width": self.width, "check_size": check_size } if y == 0: border_map = 0xb elif y == 10: border_map = 0xe else: border_map = 0xa kwargs["border_map"] = border_map html_colors[y].append('<a href="{}">{}</a>'.format( color.to_string(**COLOR_FULL_PREC), mdpopups.color_box([value], self.default_border, **kwargs))) color.lightness = color.lightness - lfac color_map = (''.join([ '<span>{}</span><br>'.format(''.join([y1 for y1 in x1])) for x1 in html_colors ]) + '\n\n') self.template_vars['color_picker'] = color_map