simetri.colors.colors
Color related operations
1"""Color related operations""" 2 3import colorsys 4 5from colorsys import ( 6 rgb_to_hls, 7 hls_to_rgb, 8 rgb_to_hsv, 9 hsv_to_rgb, 10 rgb_to_yiq, 11 yiq_to_rgb, 12) 13 14from random import random 15from dataclasses import dataclass 16from typing import Sequence 17 18import numpy as np 19 20from ..graphics.common import common_properties, Point 21from ..graphics.all_enums import ColorSpace, Types 22 23 24def change_hue(color: 'Color', delta: float) -> 'Color': 25 """Changes the hue of a color by a specified delta value. 26 27 Args: 28 color: The Color object to modify. 29 delta: The amount to adjust the hue value (between 0.0 and 1.0). 30 Positive values increase hue, negative values decrease it. 31 32 Returns: 33 A new Color instance with the modified hue value. 34 """ 35 r, g, b, a = color.rgba 36 hls = colorsys.rgb_to_hls(r, g, b) 37 r, g, b = colorsys.hls_to_rgb(hls[0] + delta, hls[1], hls[2]) 38 return Color(r, g, b, a) 39 40 41def change_lightness(color: 'Color', delta: float) -> 'Color': 42 """Changes the lightness of a color by a specified delta value. 43 44 Args: 45 color: The Color object to modify. 46 delta: The amount to adjust the lightness value (between -1.0 and 1.0). 47 Positive values increase lightness, negative values decrease it. 48 49 Returns: 50 A new Color instance with the modified lightness value. 51 """ 52 r, g, b, a = color.rgba 53 hls = colorsys.rgb_to_hls(r, g, b) 54 r, g, b = colorsys.hls_to_rgb(hls[0], hls[1] + delta, hls[2]) 55 return Color(r, g, b, a) 56 57 58def change_saturation(color: 'Color', delta: float) -> 'Color': 59 """Changes the saturation of a color by a specified delta value. 60 61 Args: 62 color: The Color object to modify. 63 delta: The amount to adjust the saturation value (between -1.0 and 1.0). 64 Positive values increase saturation, negative values decrease it. 65 66 Returns: 67 A new Color instance with the modified saturation value. 68 """ 69 r, g, b, a = color.rgba 70 hls = colorsys.rgb_to_hls(r, g, b) 71 r, g, b = colorsys.hls_to_rgb(hls[0], hls[1], hls[2] + delta) 72 return Color(r, g, b, a) 73 74 75def change_alpha(color, delta): 76 r, g, b, a = color.rgba 77 return Color(r, g, b, a + delta) 78 79 80def change_red(color, delta): 81 r, g, b, a = color.rgba 82 return Color(r + delta, g, b, a) 83 84 85def change_green(color, delta): 86 r, g, b, a = color.rgba 87 return Color(r, g + delta, b, a) 88 89 90def change_blue(color, delta): 91 r, g, b, a = color.rgba 92 return Color(r, g, b + delta, a) 93 94 95def rgb255to1(rgb): 96 return [x / 255 for x in rgb] 97 98 99def rgb1to255(rgb): 100 return [int(x * 255) for x in rgb] 101 102 103def hex_to_rgb(hexa): 104 """Convert hex to RGB.""" 105 return tuple([int(hexa[i : i + 2], 16) for i in [0, 2, 4]]) 106 107 108def rgb_to_hex(r, g, b): 109 """Convert RGB to hex.""" 110 return f"{r:X}{g:X}{b:X}" 111 112 113 114 115@dataclass 116class Color: 117 """A class representing an RGB or RGBA color. 118 119 This class represents a color in RGB or RGBA color space. The default values 120 for the components are normalized between 0.0 and 1.0. Values outside this range 121 are automatically converted from the 0-255 range. 122 123 Attributes: 124 red: The red component of the color (0.0 to 1.0). 125 green: The green component of the color (0.0 to 1.0). 126 blue: The blue component of the color (0.0 to 1.0). 127 alpha: The alpha (transparency) component (0.0 to 1.0), default is 1. 128 space: The color space, default is "rgb". 129 130 Examples: 131 >>> red = Color(1.0, 0.0, 0.0) 132 >>> transparent_blue = Color(0.0, 0.0, 1.0, 0.5) 133 >>> rgb255 = Color(255, 0, 128) # Will be automatically normalized 134 """ 135 red: int = 0 136 green: int = 0 137 blue: int = 0 138 alpha: int = 1 139 space: ColorSpace = "rgb" # for future use 140 141 def __post_init__(self): 142 """Post-initialization to ensure color values are in the correct range.""" 143 r, g, b = self.red, self.green, self.blue 144 if r < 0 or r > 1 or g < 0 or g > 1 or b < 0 or b > 1: 145 self.red = r / 255 146 self.green = g / 255 147 self.blue = b / 255 148 if self.alpha < 0 or self.alpha > 1: 149 self.alpha = self.alpha / 255 150 common_properties(self) 151 152 def __str__(self): 153 return f"Color({self.red}, {self.green}, {self.blue})" 154 155 def __repr__(self): 156 return f"Color({self.red}, {self.green}, {self.blue})" 157 158 def copy(self): 159 return Color(self.red, self.green, self.blue, self.alpha) 160 161 @property 162 def __key__(self): 163 return (self.red, self.green, self.blue) 164 165 def __hash__(self): 166 return hash(self.__key__) 167 168 @property 169 def name(self): 170 # search for the color in the named colors 171 pass 172 173 def __eq__(self, other): 174 if isinstance(other, Color): 175 return self.__key__ == other.__key__ 176 else: 177 return False 178 179 @property 180 def rgb(self): 181 return (self.red, self.green, self.blue) 182 183 @property 184 def rgba(self): 185 return (self.red, self.green, self.blue, self.alpha) 186 187 @property 188 def rgb255(self): 189 r, g, b = self.rgb 190 if r > 1 or g > 1 or b > 1: 191 return (r, g, b) 192 return tuple(round(i * 255) for i in self.rgb) 193 194 @property 195 def rgba255(self): 196 return tuple(round(i * 255) for i in self.rgba) 197 198 199def map_color(r:float, g:float, b:float, r_max:float, g_max:float, 200 b_max:float) -> Color: 201 """Map RGB values to a range of 0-255.""" 202 i_range = range(256) 203 r_range = np.arange(0, r_max, r_max/256) 204 g_range = np.arange(0, g_max, g_max/256) 205 b_range = np.arange(0, b_max, b_max/256) 206 207 r_ = np.interp(r, r_range, i_range) 208 g_ = np.interp(g, g_range, i_range) 209 b_ = np.interp(b, b_range, i_range) 210 211 return Color(r_, g_, b_) 212 213def blend(color1: Color, percent: int, color2: Color): 214 """percent% of color1 and (100-percent)% of color2 215 blended together to create a new color.""" 216 percent = percent / 100 217 r1, g1, b1 = color1 218 r2, g2, b2 = color2 219 220 r_blend = r1 * percent + r2 * (1 - percent) 221 g_blend = g1 * percent + g2 * (1 - percent) 222 b_blend = b1 * percent + b2 * (1 - percent) 223 224 return Color(r_blend, g_blend, b_blend) 225 226 227def get_color(value): 228 """ 229 if value is [r, g, b] return Color(r, g, b) 230 if value is a string return Color(value) 231 if value is a Color return value 232 """ 233 if isinstance(value, Color): 234 return value 235 elif isinstance(value, str): 236 return Color(value) 237 elif isinstance(value, (list, tuple)): 238 return Color(*value) 239 else: 240 raise TypeError("Invalid color value") 241 242 243def check_color(color): 244 if isinstance(color, Color): 245 return color 246 elif isinstance(color, (str, tuple, list)): 247 return Color(*color) 248 else: 249 raise ValueError( 250 f"Color must be a Color instance, a string, a tuple or a list. Got {color}" 251 ) 252 253 254def rgb2hls(r, g, b): 255 return rgb_to_hls(r, g, b) 256 257 258def hls2rgb(h, l, s): 259 return hls_to_rgb(h, l, s) 260 261 262def rgb2hsv(r, g, b): 263 return rgb_to_hsv(r, g, b) 264 265 266def hsv2rgb(h, s, v): 267 return hsv_to_rgb(h, s, v) 268 269 270def rgb2yiq(r, g, b): 271 return rgb_to_yiq(r, g, b) 272 273 274def yiq2rgb(y, i, q): 275 return yiq_to_rgb(y, i, q) 276 277 278def rgb2hex(rgb): 279 """Convert an RGB tuple to a hex color value.""" 280 r, g, b = rgb 281 return f"#{r:02x}{g:02x}{b:02x}" 282 283 284def hex2rgb(hex_val): 285 """Convert a hex color value to an RGB tuple.""" 286 hex_val = hex_val.strip("#") 287 return tuple(round(int(hex_val[i : i + 2], 16) / 255, 3) for i in (0, 2, 4)) 288 289 290def cmyk2rgb(c, m, y, k): 291 """Convert a CMYK color value to an RGB tuple.""" 292 r = 1 - min(1, c * (1 - k) + k) 293 g = 1 - min(1, m * (1 - k) + k) 294 b = 1 - min(1, y * (1 - k) + k) 295 return (r, g, b) 296 297 298def random_color(): 299 """Return a random color.""" 300 return Color(random(), random(), random()) 301 302 303@dataclass 304class LinearGradient: 305 """A class representing a linear gradient. 306 307 This class defines a linear gradient between two points with specified colors. 308 309 Attributes: 310 x1: The x-coordinate of the starting point. 311 y1: The y-coordinate of the starting point. 312 x2: The x-coordinate of the ending point. 313 y2: The y-coordinate of the ending point. 314 colors: A sequence of Color objects defining the gradient colors. 315 positions: A sequence of Point objects defining the gradient positions. 316 extend: Whether to extend the gradient beyond its endpoints. 317 318 Examples: 319 >>> from simetri.graphics.common import Point 320 >>> gradient = LinearGradient(0, 0, 100, 100, 321 ... [Color(1, 0, 0), Color(0, 0, 1)], 322 ... [Point(0, 0), Point(100, 100)]) 323 """ 324 x1: float = 0.0 325 y1: float = 0.0 326 x2: float = 0.0 327 y2: float = 0.0 328 colors: Sequence[Color] = None 329 positions: Sequence[Point] = None 330 extend: bool = False 331 332 def __post_init__(self): 333 self.type = Types.GRADIENT 334 self.subtype = Types.LINEAR 335 common_properties(self) 336 337 338@dataclass 339class RadialGradient: 340 """A class representing a radial gradient. 341 342 This class defines a radial gradient that radiates outward from a center point. 343 344 Attributes: 345 x: The x-coordinate of the center point. 346 y: The y-coordinate of the center point. 347 radius: The radius of the gradient. 348 colors: A sequence of Color objects defining the gradient colors. 349 positions: A sequence of Point objects defining the gradient positions. 350 extend: Whether to extend the gradient beyond its defined radius. 351 352 Examples: 353 >>> from simetri.graphics.common import Point 354 >>> gradient = RadialGradient(50, 50, 30, 355 ... [Color(1, 1, 1), Color(0, 0, 0)], 356 ... [Point(50, 50), Point(80, 50)]) 357 """ 358 x: float = 0.0 359 y: float = 0.0 360 radius: float = 0.0 361 colors: Sequence[Color] = None 362 positions: Sequence[Point] = None 363 extend: bool = False 364 365 def __post_init__(self): 366 self.type = Types.GRADIENT 367 self.subtype = Types.RADIAL 368 common_properties(self) 369 370 371# <xcolor> TikZ library colors 372# Apricot, Aquamarine, Bittersweet, Black, Blue, BlueGreen, BlueViolet, BrickRed, Brown, BurntOrange, CadetBlue, 373# CarnationPink, Cerulean, CornflowerBlue, Cyan, Dandelion, DarkOrchid, Emerald, ForestGreen, Fuchsia, Goldenrod, 374# Gray, Green, GreenYellow, JungleGreen, Lavender, LimeGreen, Magenta, Mahogany, Maroon, Melon, MidnightBlue, 375# Mulberry, NavyBlue, OliveGreen, Orange, OrangeRed, Orchid, Peach, Periwinkle, PineGreen, Plum, ProcessBlue, 376# Purple, RawSienna, Red, RedOrange, RedViolet, Rhodamine, RoyalBlue, RoyalPurple, RubineRed, Salmon, SeaGreen, 377# Sepia, SkyBlue, SpringGreen, Tan, TealBlue, Thistle, Turquoise, Violet, VioletRed, White, WildStrawberry, 378# Yellow, YellowGreen, YellowOrange 379 380 381# Named colors from xkcd color survey 382 383acid_green = Color(0.561, 0.996, 0.035) 384adobe = Color(0.741, 0.424, 0.282) 385algae = Color(0.329, 0.675, 0.408) 386algae_green = Color(0.129, 0.765, 0.435) 387almost_black = Color(0.027, 0.051, 0.051) 388amber = Color(0.996, 0.702, 0.031) 389amethyst = Color(0.608, 0.373, 0.753) 390apple = Color(0.431, 0.796, 0.235) 391apple_green = Color(0.463, 0.804, 0.149) 392apricot = Color(1.0, 0.694, 0.427) 393aqua = Color(0.075, 0.918, 0.788) 394aqua_blue = Color(0.008, 0.847, 0.914) 395aqua_green = Color(0.071, 0.882, 0.576) 396aqua_marine = Color(0.18, 0.91, 0.733) 397aquamarine = Color(0.016, 0.847, 0.698) 398army_green = Color(0.294, 0.365, 0.086) 399asparagus = Color(0.467, 0.671, 0.337) 400aubergine = Color(0.239, 0.027, 0.204) 401auburn = Color(0.604, 0.188, 0.004) 402avocado = Color(0.565, 0.694, 0.204) 403avocado_green = Color(0.529, 0.663, 0.133) 404azul = Color(0.114, 0.365, 0.925) 405azure = Color(0.024, 0.604, 0.953) 406baby_blue = Color(0.635, 0.812, 0.996) 407baby_green = Color(0.549, 1.0, 0.62) 408baby_pink = Color(1.0, 0.718, 0.808) 409baby_poo = Color(0.671, 0.565, 0.016) 410baby_poop = Color(0.576, 0.486, 0.0) 411baby_poop_green = Color(0.561, 0.596, 0.02) 412baby_puke_green = Color(0.714, 0.769, 0.024) 413baby_purple = Color(0.792, 0.608, 0.969) 414baby_shit_brown = Color(0.678, 0.565, 0.051) 415baby_shit_green = Color(0.533, 0.592, 0.09) 416banana = Color(1.0, 1.0, 0.494) 417banana_yellow = Color(0.98, 0.996, 0.294) 418barbie_pink = Color(0.996, 0.275, 0.647) 419barf_green = Color(0.58, 0.675, 0.008) 420barney = Color(0.675, 0.114, 0.722) 421barney_purple = Color(0.627, 0.016, 0.596) 422battleship_grey = Color(0.42, 0.486, 0.522) 423battleship_gray = Color(0.42, 0.486, 0.522) 424beige = Color(0.902, 0.855, 0.651) 425berry = Color(0.6, 0.059, 0.294) 426bile = Color(0.71, 0.765, 0.024) 427black = Color(0.0, 0.0, 0.0) 428bland = Color(0.686, 0.659, 0.545) 429blood = Color(0.467, 0.0, 0.004) 430blood_orange = Color(0.996, 0.294, 0.012) 431blood_red = Color(0.596, 0.0, 0.008) 432blue = Color(0.012, 0.263, 0.875) 433blue_blue = Color(0.133, 0.259, 0.78) 434blue_green = Color(0.075, 0.494, 0.427) 435blue_grey = Color(0.376, 0.486, 0.557) 436blue_gray = Color(0.376, 0.486, 0.557) 437blue_purple = Color(0.341, 0.161, 0.808) 438blue_violet = Color(0.365, 0.024, 0.914) 439blue_with_a_hint_of_purple = Color(0.325, 0.235, 0.776) 440blue_purple = Color(0.353, 0.024, 0.937) 441blueberry = Color(0.275, 0.255, 0.588) 442bluegreen = Color(0.004, 0.478, 0.475) 443bluegrey = Color(0.522, 0.639, 0.698) 444bluegray = Color(0.522, 0.639, 0.698) 445bluey_green = Color(0.169, 0.694, 0.475) 446bluey_grey = Color(0.537, 0.627, 0.69) 447bluey_gray = Color(0.537, 0.627, 0.69) 448bluey_purple = Color(0.384, 0.255, 0.78) 449bluish = Color(0.161, 0.463, 0.733) 450bluish_green = Color(0.063, 0.651, 0.455) 451bluish_grey = Color(0.455, 0.545, 0.592) 452bluish_gray = Color(0.455, 0.545, 0.592) 453bluish_purple = Color(0.439, 0.231, 0.906) 454blurple = Color(0.333, 0.224, 0.8) 455blush = Color(0.949, 0.62, 0.557) 456blush_pink = Color(0.996, 0.51, 0.549) 457booger = Color(0.608, 0.71, 0.235) 458booger_green = Color(0.588, 0.706, 0.012) 459bordeaux = Color(0.482, 0.0, 0.173) 460boring_green = Color(0.388, 0.702, 0.396) 461bottle_green = Color(0.016, 0.29, 0.02) 462brick = Color(0.627, 0.212, 0.137) 463brick_orange = Color(0.757, 0.29, 0.035) 464brick_red = Color(0.561, 0.078, 0.008) 465bright_aqua = Color(0.043, 0.976, 0.918) 466bright_blue = Color(0.004, 0.396, 0.988) 467bright_cyan = Color(0.255, 0.992, 0.996) 468bright_green = Color(0.004, 1.0, 0.027) 469bright_lavender = Color(0.78, 0.376, 1.0) 470bright_light_blue = Color(0.149, 0.969, 0.992) 471bright_light_green = Color(0.176, 0.996, 0.329) 472bright_lilac = Color(0.788, 0.369, 0.984) 473bright_lime = Color(0.529, 0.992, 0.02) 474bright_lime_green = Color(0.396, 0.996, 0.031) 475bright_magenta = Color(1.0, 0.031, 0.91) 476bright_olive = Color(0.612, 0.733, 0.016) 477bright_orange = Color(1.0, 0.357, 0.0) 478bright_pink = Color(0.996, 0.004, 0.694) 479bright_purple = Color(0.745, 0.012, 0.992) 480bright_red = Color(1.0, 0.0, 0.051) 481bright_sea_green = Color(0.02, 1.0, 0.651) 482bright_sky_blue = Color(0.008, 0.8, 0.996) 483bright_teal = Color(0.004, 0.976, 0.776) 484bright_turquoise = Color(0.059, 0.996, 0.976) 485bright_violet = Color(0.678, 0.039, 0.992) 486bright_yellow = Color(1.0, 0.992, 0.004) 487bright_yellow_green = Color(0.616, 1.0, 0.0) 488british_racing_green = Color(0.02, 0.282, 0.051) 489bronze = Color(0.659, 0.475, 0.0) 490brown = Color(0.396, 0.216, 0.0) 491brown_green = Color(0.439, 0.424, 0.067) 492brown_grey = Color(0.553, 0.518, 0.408) 493brown_gray = Color(0.553, 0.518, 0.408) 494brown_orange = Color(0.725, 0.412, 0.008) 495brown_red = Color(0.573, 0.169, 0.02) 496brown_yellow = Color(0.698, 0.592, 0.02) 497brownish = Color(0.612, 0.427, 0.341) 498brownish_green = Color(0.416, 0.431, 0.035) 499brownish_grey = Color(0.525, 0.467, 0.373) 500brownish_gray = Color(0.525, 0.467, 0.373) 501brownish_orange = Color(0.796, 0.467, 0.137) 502brownish_pink = Color(0.761, 0.494, 0.475) 503brownish_purple = Color(0.463, 0.259, 0.306) 504brownish_red = Color(0.62, 0.212, 0.137) 505brownish_yellow = Color(0.788, 0.69, 0.012) 506browny_green = Color(0.435, 0.424, 0.039) 507browny_orange = Color(0.792, 0.42, 0.008) 508bruise = Color(0.494, 0.251, 0.443) 509bubble_gum_pink = Color(1.0, 0.412, 0.686) 510bubblegum = Color(1.0, 0.424, 0.71) 511bubblegum_pink = Color(0.996, 0.514, 0.8) 512buff = Color(0.996, 0.965, 0.62) 513burgundy = Color(0.38, 0.0, 0.137) 514burnt_orange = Color(0.753, 0.306, 0.004) 515burnt_red = Color(0.624, 0.137, 0.02) 516burnt_siena = Color(0.718, 0.322, 0.012) 517burnt_sienna = Color(0.69, 0.306, 0.059) 518burnt_umber = Color(0.627, 0.271, 0.055) 519burnt_yellow = Color(0.835, 0.671, 0.035) 520burple = Color(0.408, 0.196, 0.89) 521butter = Color(1.0, 1.0, 0.506) 522butter_yellow = Color(1.0, 0.992, 0.455) 523butterscotch = Color(0.992, 0.694, 0.278) 524cadet_blue = Color(0.306, 0.455, 0.588) 525camel = Color(0.776, 0.624, 0.349) 526camo = Color(0.498, 0.561, 0.306) 527camo_green = Color(0.322, 0.396, 0.145) 528camouflage_green = Color(0.294, 0.38, 0.075) 529canary = Color(0.992, 1.0, 0.388) 530canary_yellow = Color(1.0, 0.996, 0.251) 531candy_pink = Color(1.0, 0.388, 0.914) 532caramel = Color(0.686, 0.435, 0.035) 533carmine = Color(0.616, 0.008, 0.086) 534carnation = Color(0.992, 0.475, 0.561) 535carnation_pink = Color(1.0, 0.498, 0.655) 536carolina_blue = Color(0.541, 0.722, 0.996) 537celadon = Color(0.745, 0.992, 0.718) 538celery = Color(0.757, 0.992, 0.584) 539cement = Color(0.647, 0.639, 0.569) 540cerise = Color(0.871, 0.047, 0.384) 541cerulean = Color(0.016, 0.522, 0.82) 542cerulean_blue = Color(0.02, 0.431, 0.933) 543charcoal = Color(0.204, 0.22, 0.216) 544charcoal_grey = Color(0.235, 0.255, 0.259) 545charcoal_gray = Color(0.235, 0.255, 0.259) 546chartreuse = Color(0.757, 0.973, 0.039) 547cherry = Color(0.812, 0.008, 0.204) 548cherry_red = Color(0.969, 0.008, 0.165) 549chestnut = Color(0.455, 0.157, 0.008) 550chocolate = Color(0.239, 0.11, 0.008) 551chocolate_brown = Color(0.255, 0.098, 0.0) 552cinnamon = Color(0.675, 0.31, 0.024) 553claret = Color(0.408, 0.0, 0.094) 554clay = Color(0.714, 0.416, 0.314) 555clay_brown = Color(0.698, 0.443, 0.239) 556clear_blue = Color(0.141, 0.478, 0.992) 557cloudy_blue = Color(0.675, 0.761, 0.851) 558cobalt = Color(0.118, 0.282, 0.561) 559cobalt_blue = Color(0.012, 0.039, 0.655) 560cocoa = Color(0.529, 0.373, 0.259) 561coffee = Color(0.651, 0.506, 0.298) 562cool_blue = Color(0.286, 0.518, 0.722) 563cool_green = Color(0.2, 0.722, 0.392) 564cool_grey = Color(0.584, 0.639, 0.651) 565cool_gray = Color(0.584, 0.639, 0.651) 566copper = Color(0.714, 0.388, 0.145) 567coral = Color(0.988, 0.353, 0.314) 568coral_pink = Color(1.0, 0.38, 0.388) 569cornflower = Color(0.416, 0.475, 0.969) 570cornflower_blue = Color(0.318, 0.439, 0.843) 571cranberry = Color(0.62, 0.0, 0.227) 572cream = Color(1.0, 1.0, 0.761) 573creme = Color(1.0, 1.0, 0.714) 574crimson = Color(0.549, 0.0, 0.059) 575custard = Color(1.0, 0.992, 0.471) 576cyan = Color(0.0, 1.0, 1.0) 577dandelion = Color(0.996, 0.875, 0.031) 578dark = Color(0.106, 0.141, 0.192) 579dark_aqua = Color(0.02, 0.412, 0.42) 580dark_aquamarine = Color(0.004, 0.451, 0.443) 581dark_beige = Color(0.675, 0.576, 0.384) 582dark_blue = Color(0.0, 0.012, 0.357) 583dark_blue_green = Color(0.0, 0.322, 0.286) 584dark_blue_grey = Color(0.122, 0.231, 0.302) 585dark_blue_gray = Color(0.122, 0.231, 0.302) 586dark_brown = Color(0.204, 0.11, 0.008) 587dark_coral = Color(0.812, 0.322, 0.306) 588dark_cream = Color(1.0, 0.953, 0.604) 589dark_cyan = Color(0.039, 0.533, 0.541) 590dark_forest_green = Color(0.0, 0.176, 0.016) 591dark_fuchsia = Color(0.616, 0.027, 0.349) 592dark_gold = Color(0.71, 0.58, 0.063) 593dark_grass_green = Color(0.22, 0.502, 0.016) 594dark_green = Color(0.012, 0.208, 0.0) 595dark_green_blue = Color(0.122, 0.388, 0.341) 596dark_grey = Color(0.212, 0.216, 0.216) 597dark_gray = Color(0.212, 0.216, 0.216) 598dark_grey_blue = Color(0.161, 0.275, 0.357) 599dark_gray_blue = Color(0.161, 0.275, 0.357) 600dark_hot_pink = Color(0.851, 0.004, 0.4) 601dark_indigo = Color(0.122, 0.035, 0.329) 602dark_khaki = Color(0.608, 0.561, 0.333) 603dark_lavender = Color(0.522, 0.404, 0.596) 604dark_lilac = Color(0.612, 0.427, 0.647) 605dark_lime = Color(0.518, 0.718, 0.004) 606dark_lime_green = Color(0.494, 0.741, 0.004) 607dark_magenta = Color(0.588, 0.0, 0.337) 608dark_maroon = Color(0.235, 0.0, 0.031) 609dark_mauve = Color(0.529, 0.298, 0.384) 610dark_mint = Color(0.282, 0.753, 0.447) 611dark_mint_green = Color(0.125, 0.753, 0.451) 612dark_mustard = Color(0.659, 0.537, 0.02) 613dark_navy = Color(0.0, 0.016, 0.208) 614dark_navy_blue = Color(0.0, 0.008, 0.18) 615dark_olive = Color(0.216, 0.243, 0.008) 616dark_olive_green = Color(0.235, 0.302, 0.012) 617dark_orange = Color(0.776, 0.318, 0.008) 618dark_pastel_green = Color(0.337, 0.682, 0.341) 619dark_peach = Color(0.871, 0.494, 0.365) 620dark_periwinkle = Color(0.4, 0.373, 0.82) 621dark_pink = Color(0.796, 0.255, 0.42) 622dark_plum = Color(0.247, 0.004, 0.173) 623dark_purple = Color(0.208, 0.024, 0.243) 624dark_red = Color(0.518, 0.0, 0.0) 625dark_rose = Color(0.71, 0.282, 0.365) 626dark_royal_blue = Color(0.008, 0.024, 0.435) 627dark_sage = Color(0.349, 0.522, 0.337) 628dark_salmon = Color(0.784, 0.353, 0.325) 629dark_sand = Color(0.659, 0.561, 0.349) 630dark_sea_green = Color(0.067, 0.529, 0.365) 631dark_seafoam = Color(0.122, 0.71, 0.478) 632dark_seafoam_green = Color(0.243, 0.686, 0.463) 633dark_sky_blue = Color(0.267, 0.557, 0.894) 634dark_slate_blue = Color(0.129, 0.278, 0.38) 635dark_tan = Color(0.686, 0.533, 0.29) 636dark_taupe = Color(0.498, 0.408, 0.306) 637dark_teal = Color(0.004, 0.302, 0.306) 638dark_turquoise = Color(0.016, 0.361, 0.353) 639dark_violet = Color(0.204, 0.004, 0.247) 640dark_yellow = Color(0.835, 0.714, 0.039) 641dark_yellow_green = Color(0.447, 0.561, 0.008) 642darkblue = Color(0.012, 0.027, 0.392) 643darkgreen = Color(0.02, 0.286, 0.027) 644darkish_blue = Color(0.004, 0.255, 0.51) 645darkish_green = Color(0.157, 0.486, 0.216) 646darkish_pink = Color(0.855, 0.275, 0.49) 647darkish_purple = Color(0.459, 0.098, 0.451) 648darkish_red = Color(0.663, 0.012, 0.031) 649deep_aqua = Color(0.031, 0.471, 0.498) 650deep_blue = Color(0.016, 0.008, 0.451) 651deep_brown = Color(0.255, 0.008, 0.0) 652deep_green = Color(0.008, 0.349, 0.059) 653deep_lavender = Color(0.553, 0.369, 0.718) 654deep_lilac = Color(0.588, 0.431, 0.741) 655deep_magenta = Color(0.627, 0.008, 0.361) 656deep_orange = Color(0.863, 0.302, 0.004) 657deep_pink = Color(0.796, 0.004, 0.384) 658deep_purple = Color(0.212, 0.004, 0.247) 659deep_red = Color(0.604, 0.008, 0.0) 660deep_rose = Color(0.78, 0.278, 0.404) 661deep_sea_blue = Color(0.004, 0.329, 0.51) 662deep_sky_blue = Color(0.051, 0.459, 0.973) 663deep_teal = Color(0.0, 0.333, 0.353) 664deep_turquoise = Color(0.004, 0.451, 0.455) 665deep_violet = Color(0.286, 0.024, 0.282) 666denim = Color(0.231, 0.388, 0.549) 667denim_blue = Color(0.231, 0.357, 0.573) 668desert = Color(0.8, 0.678, 0.376) 669diarrhea = Color(0.624, 0.514, 0.012) 670dirt = Color(0.541, 0.431, 0.271) 671dirt_brown = Color(0.514, 0.396, 0.224) 672dirty_blue = Color(0.247, 0.51, 0.616) 673dirty_green = Color(0.4, 0.494, 0.173) 674dirty_orange = Color(0.784, 0.463, 0.024) 675dirty_pink = Color(0.792, 0.482, 0.502) 676dirty_purple = Color(0.451, 0.29, 0.396) 677dirty_yellow = Color(0.804, 0.773, 0.039) 678dodger_blue = Color(0.243, 0.51, 0.988) 679drab = Color(0.51, 0.514, 0.267) 680drab_green = Color(0.455, 0.584, 0.318) 681dried_blood = Color(0.294, 0.004, 0.004) 682duck_egg_blue = Color(0.765, 0.984, 0.957) 683dull_blue = Color(0.286, 0.459, 0.612) 684dull_brown = Color(0.529, 0.431, 0.294) 685dull_green = Color(0.455, 0.651, 0.384) 686dull_orange = Color(0.847, 0.525, 0.231) 687dull_pink = Color(0.835, 0.525, 0.616) 688dull_purple = Color(0.518, 0.349, 0.494) 689dull_red = Color(0.733, 0.247, 0.247) 690dull_teal = Color(0.373, 0.62, 0.561) 691dull_yellow = Color(0.933, 0.863, 0.357) 692dusk = Color(0.306, 0.329, 0.506) 693dusk_blue = Color(0.149, 0.325, 0.553) 694dusky_blue = Color(0.278, 0.373, 0.58) 695dusky_pink = Color(0.8, 0.478, 0.545) 696dusky_purple = Color(0.537, 0.357, 0.482) 697dusky_rose = Color(0.729, 0.408, 0.451) 698dust = Color(0.698, 0.6, 0.431) 699dusty_blue = Color(0.353, 0.525, 0.678) 700dusty_green = Color(0.463, 0.663, 0.451) 701dusty_lavender = Color(0.675, 0.525, 0.659) 702dusty_orange = Color(0.941, 0.514, 0.227) 703dusty_pink = Color(0.835, 0.541, 0.58) 704dusty_purple = Color(0.51, 0.373, 0.529) 705dusty_red = Color(0.725, 0.282, 0.306) 706dusty_rose = Color(0.753, 0.451, 0.478) 707dusty_teal = Color(0.298, 0.565, 0.522) 708earth = Color(0.635, 0.396, 0.243) 709easter_green = Color(0.549, 0.992, 0.494) 710easter_purple = Color(0.753, 0.443, 0.996) 711ecru = Color(0.996, 1.0, 0.792) 712egg_shell = Color(1.0, 0.988, 0.769) 713eggplant = Color(0.22, 0.031, 0.208) 714eggplant_purple = Color(0.263, 0.02, 0.255) 715eggshell = Color(1.0, 1.0, 0.831) 716eggshell_blue = Color(0.769, 1.0, 0.969) 717electric_blue = Color(0.024, 0.322, 1.0) 718electric_green = Color(0.129, 0.988, 0.051) 719electric_lime = Color(0.659, 1.0, 0.016) 720electric_pink = Color(1.0, 0.016, 0.565) 721electric_purple = Color(0.667, 0.137, 1.0) 722emerald = Color(0.004, 0.627, 0.286) 723emerald_green = Color(0.008, 0.561, 0.118) 724evergreen = Color(0.02, 0.278, 0.165) 725faded_blue = Color(0.396, 0.549, 0.733) 726faded_green = Color(0.482, 0.698, 0.455) 727faded_orange = Color(0.941, 0.58, 0.302) 728faded_pink = Color(0.871, 0.616, 0.675) 729faded_purple = Color(0.569, 0.431, 0.6) 730faded_red = Color(0.827, 0.286, 0.306) 731faded_yellow = Color(0.996, 1.0, 0.498) 732fawn = Color(0.812, 0.686, 0.482) 733fern = Color(0.388, 0.663, 0.314) 734fern_green = Color(0.329, 0.553, 0.267) 735fire_engine_red = Color(0.996, 0.0, 0.008) 736flat_blue = Color(0.235, 0.451, 0.659) 737flat_green = Color(0.412, 0.616, 0.298) 738fluorescent_green = Color(0.031, 1.0, 0.031) 739fluro_green = Color(0.039, 1.0, 0.008) 740foam_green = Color(0.565, 0.992, 0.663) 741forest = Color(0.043, 0.333, 0.035) 742forest_green = Color(0.024, 0.278, 0.047) 743forrest_green = Color(0.082, 0.267, 0.024) 744french_blue = Color(0.263, 0.42, 0.678) 745fresh_green = Color(0.412, 0.847, 0.31) 746frog_green = Color(0.345, 0.737, 0.031) 747fuchsia = Color(0.929, 0.051, 0.851) 748gold = Color(0.859, 0.706, 0.047) 749golden = Color(0.961, 0.749, 0.012) 750golden_brown = Color(0.698, 0.478, 0.004) 751golden_rod = Color(0.976, 0.737, 0.031) 752golden_yellow = Color(0.996, 0.776, 0.082) 753goldenrod = Color(0.98, 0.761, 0.02) 754grape = Color(0.424, 0.204, 0.38) 755grape_purple = Color(0.365, 0.078, 0.318) 756grapefruit = Color(0.992, 0.349, 0.337) 757grass = Color(0.361, 0.675, 0.176) 758grass_green = Color(0.247, 0.608, 0.043) 759grassy_green = Color(0.255, 0.612, 0.012) 760green = Color(0.082, 0.69, 0.102) 761green_apple = Color(0.369, 0.863, 0.122) 762green_blue = Color(0.024, 0.706, 0.545) 763green_brown = Color(0.329, 0.306, 0.012) 764green_grey = Color(0.467, 0.573, 0.435) 765green_gray = Color(0.467, 0.573, 0.435) 766green_teal = Color(0.047, 0.71, 0.467) 767green_yellow = Color(0.788, 1.0, 0.153) 768green_blue = Color(0.004, 0.753, 0.553) 769green_yellow = Color(0.71, 0.808, 0.031) 770greenblue = Color(0.137, 0.769, 0.545) 771greenish = Color(0.251, 0.639, 0.408) 772greenish_beige = Color(0.788, 0.82, 0.475) 773greenish_blue = Color(0.043, 0.545, 0.529) 774greenish_brown = Color(0.412, 0.38, 0.071) 775greenish_cyan = Color(0.165, 0.996, 0.718) 776greenish_grey = Color(0.588, 0.682, 0.553) 777greenish_gray = Color(0.588, 0.682, 0.553) 778greenish_tan = Color(0.737, 0.796, 0.478) 779greenish_teal = Color(0.196, 0.749, 0.518) 780greenish_turquoise = Color(0.0, 0.984, 0.69) 781greenish_yellow = Color(0.804, 0.992, 0.008) 782greeny_blue = Color(0.259, 0.702, 0.584) 783greeny_brown = Color(0.412, 0.376, 0.024) 784greeny_grey = Color(0.494, 0.627, 0.478) 785greeny_gray = Color(0.494, 0.627, 0.478) 786greeny_yellow = Color(0.776, 0.973, 0.031) 787grey = Color(0.573, 0.584, 0.569) 788gray = Color(0.573, 0.584, 0.569) 789grey_blue = Color(0.42, 0.545, 0.643) 790gray_blue = Color(0.42, 0.545, 0.643) 791grey_brown = Color(0.498, 0.439, 0.325) 792gray_brown = Color(0.498, 0.439, 0.325) 793grey_green = Color(0.471, 0.608, 0.451) 794gray_green = Color(0.471, 0.608, 0.451) 795grey_pink = Color(0.765, 0.565, 0.608) 796gray_pink = Color(0.765, 0.565, 0.608) 797grey_purple = Color(0.51, 0.427, 0.549) 798gray_purple = Color(0.51, 0.427, 0.549) 799grey_teal = Color(0.369, 0.608, 0.541) 800gray_teal = Color(0.369, 0.608, 0.541) 801grey_blue = Color(0.392, 0.49, 0.557) 802gray_blue = Color(0.392, 0.49, 0.557) 803grey_green = Color(0.525, 0.631, 0.49) 804gray_green = Color(0.525, 0.631, 0.49) 805greyblue = Color(0.467, 0.631, 0.71) 806grayblue = Color(0.467, 0.631, 0.71) 807greyish = Color(0.659, 0.643, 0.584) 808grayish = Color(0.659, 0.643, 0.584) 809greyish_blue = Color(0.369, 0.506, 0.616) 810grayish_blue = Color(0.369, 0.506, 0.616) 811greyish_brown = Color(0.478, 0.416, 0.31) 812grayish_brown = Color(0.478, 0.416, 0.31) 813greyish_green = Color(0.51, 0.651, 0.49) 814grayish_green = Color(0.51, 0.651, 0.49) 815greyish_pink = Color(0.784, 0.553, 0.58) 816grayish_pink = Color(0.784, 0.553, 0.58) 817greyish_purple = Color(0.533, 0.443, 0.569) 818grayish_purple = Color(0.533, 0.443, 0.569) 819greyish_teal = Color(0.443, 0.624, 0.569) 820grayish_teal = Color(0.443, 0.624, 0.569) 821gross_green = Color(0.627, 0.749, 0.086) 822gunmetal = Color(0.325, 0.384, 0.404) 823hazel = Color(0.557, 0.463, 0.094) 824heather = Color(0.643, 0.518, 0.675) 825heliotrope = Color(0.851, 0.31, 0.961) 826highlighter_green = Color(0.106, 0.988, 0.024) 827hospital_green = Color(0.608, 0.898, 0.667) 828hot_green = Color(0.145, 1.0, 0.161) 829hot_magenta = Color(0.961, 0.016, 0.788) 830hot_pink = Color(1.0, 0.008, 0.553) 831hot_purple = Color(0.796, 0.0, 0.961) 832hunter_green = Color(0.043, 0.251, 0.031) 833ice = Color(0.839, 1.0, 0.98) 834ice_blue = Color(0.843, 1.0, 0.996) 835icky_green = Color(0.561, 0.682, 0.133) 836indian_red = Color(0.522, 0.055, 0.016) 837indigo = Color(0.22, 0.008, 0.51) 838indigo_blue = Color(0.227, 0.094, 0.694) 839iris = Color(0.384, 0.345, 0.769) 840irish_green = Color(0.004, 0.584, 0.161) 841ivory = Color(1.0, 1.0, 0.796) 842jade = Color(0.122, 0.655, 0.455) 843jade_green = Color(0.169, 0.686, 0.416) 844jungle_green = Color(0.016, 0.51, 0.263) 845kelley_green = Color(0.0, 0.576, 0.216) 846kelly_green = Color(0.008, 0.671, 0.18) 847kermit_green = Color(0.361, 0.698, 0.0) 848key_lime = Color(0.682, 1.0, 0.431) 849khaki = Color(0.667, 0.651, 0.384) 850khaki_green = Color(0.447, 0.525, 0.224) 851kiwi = Color(0.612, 0.937, 0.263) 852kiwi_green = Color(0.557, 0.898, 0.247) 853lavender = Color(0.78, 0.624, 0.937) 854lavender_blue = Color(0.545, 0.533, 0.973) 855lavender_pink = Color(0.867, 0.522, 0.843) 856lawn_green = Color(0.302, 0.643, 0.035) 857leaf = Color(0.443, 0.667, 0.204) 858leaf_green = Color(0.361, 0.663, 0.016) 859leafy_green = Color(0.318, 0.718, 0.231) 860leather = Color(0.675, 0.455, 0.204) 861lemon = Color(0.992, 1.0, 0.322) 862lemon_green = Color(0.678, 0.973, 0.008) 863lemon_lime = Color(0.749, 0.996, 0.157) 864lemon_yellow = Color(0.992, 1.0, 0.22) 865lichen = Color(0.561, 0.714, 0.482) 866light_aqua = Color(0.549, 1.0, 0.859) 867light_aquamarine = Color(0.482, 0.992, 0.78) 868light_beige = Color(1.0, 0.996, 0.714) 869light_blue = Color(0.584, 0.816, 0.988) 870light_blue_green = Color(0.494, 0.984, 0.702) 871light_blue_grey = Color(0.718, 0.788, 0.886) 872light_blue_gray = Color(0.718, 0.788, 0.886) 873light_bluish_green = Color(0.463, 0.992, 0.659) 874light_bright_green = Color(0.325, 0.996, 0.361) 875light_brown = Color(0.678, 0.506, 0.314) 876light_burgundy = Color(0.659, 0.255, 0.357) 877light_cyan = Color(0.675, 1.0, 0.988) 878light_eggplant = Color(0.537, 0.271, 0.522) 879light_forest_green = Color(0.31, 0.569, 0.325) 880light_gold = Color(0.992, 0.863, 0.361) 881light_grass_green = Color(0.604, 0.969, 0.392) 882light_green = Color(0.588, 0.976, 0.482) 883light_green_blue = Color(0.337, 0.988, 0.635) 884light_greenish_blue = Color(0.388, 0.969, 0.706) 885light_grey = Color(0.847, 0.863, 0.839) 886light_gray = Color(0.847, 0.863, 0.839) 887light_grey_blue = Color(0.616, 0.737, 0.831) 888light_gray_blue = Color(0.616, 0.737, 0.831) 889light_grey_green = Color(0.718, 0.882, 0.631) 890light_gray_green = Color(0.718, 0.882, 0.631) 891light_indigo = Color(0.427, 0.353, 0.812) 892light_khaki = Color(0.902, 0.949, 0.635) 893light_lavendar = Color(0.937, 0.753, 0.996) 894light_lavender = Color(0.875, 0.773, 0.996) 895light_light_blue = Color(0.792, 1.0, 0.984) 896light_light_green = Color(0.784, 1.0, 0.69) 897light_lilac = Color(0.929, 0.784, 1.0) 898light_lime = Color(0.682, 0.992, 0.424) 899light_lime_green = Color(0.725, 1.0, 0.4) 900light_magenta = Color(0.98, 0.373, 0.969) 901light_maroon = Color(0.635, 0.282, 0.341) 902light_mauve = Color(0.761, 0.573, 0.631) 903light_mint = Color(0.714, 1.0, 0.733) 904light_mint_green = Color(0.651, 0.984, 0.698) 905light_moss_green = Color(0.651, 0.784, 0.459) 906light_mustard = Color(0.969, 0.835, 0.376) 907light_navy = Color(0.082, 0.314, 0.518) 908light_navy_blue = Color(0.18, 0.353, 0.533) 909light_neon_green = Color(0.306, 0.992, 0.329) 910light_olive = Color(0.675, 0.749, 0.412) 911light_olive_green = Color(0.643, 0.745, 0.361) 912light_orange = Color(0.992, 0.667, 0.282) 913light_pastel_green = Color(0.698, 0.984, 0.647) 914light_pea_green = Color(0.769, 0.996, 0.51) 915light_peach = Color(1.0, 0.847, 0.694) 916light_periwinkle = Color(0.757, 0.776, 0.988) 917light_pink = Color(1.0, 0.82, 0.875) 918light_plum = Color(0.616, 0.341, 0.514) 919light_purple = Color(0.749, 0.467, 0.965) 920light_red = Color(1.0, 0.278, 0.298) 921light_rose = Color(1.0, 0.773, 0.796) 922light_royal_blue = Color(0.227, 0.18, 0.996) 923light_sage = Color(0.737, 0.925, 0.675) 924light_salmon = Color(0.996, 0.663, 0.576) 925light_sea_green = Color(0.596, 0.965, 0.69) 926light_seafoam = Color(0.627, 0.996, 0.749) 927light_seafoam_green = Color(0.655, 1.0, 0.71) 928light_sky_blue = Color(0.776, 0.988, 1.0) 929light_tan = Color(0.984, 0.933, 0.675) 930light_teal = Color(0.565, 0.894, 0.757) 931light_turquoise = Color(0.494, 0.957, 0.8) 932light_urple = Color(0.702, 0.435, 0.965) 933light_violet = Color(0.839, 0.706, 0.988) 934light_yellow = Color(1.0, 0.996, 0.478) 935light_yellow_green = Color(0.8, 0.992, 0.498) 936light_yellowish_green = Color(0.761, 1.0, 0.537) 937lightblue = Color(0.482, 0.784, 0.965) 938lighter_green = Color(0.459, 0.992, 0.388) 939lighter_purple = Color(0.647, 0.353, 0.957) 940lightgreen = Color(0.463, 1.0, 0.482) 941lightish_blue = Color(0.239, 0.478, 0.992) 942lightish_green = Color(0.38, 0.882, 0.376) 943lightish_purple = Color(0.647, 0.322, 0.902) 944lightish_red = Color(0.996, 0.184, 0.29) 945lilac = Color(0.808, 0.635, 0.992) 946liliac = Color(0.769, 0.557, 0.992) 947lime = Color(0.667, 1.0, 0.196) 948lime_green = Color(0.537, 0.996, 0.02) 949lime_yellow = Color(0.816, 0.996, 0.114) 950lipstick = Color(0.835, 0.09, 0.306) 951lipstick_red = Color(0.753, 0.008, 0.184) 952macaroni_and_cheese = Color(0.937, 0.706, 0.208) 953magenta = Color(0.761, 0.0, 0.471) 954mahogany = Color(0.29, 0.004, 0.0) 955maize = Color(0.957, 0.816, 0.329) 956mango = Color(1.0, 0.651, 0.169) 957manilla = Color(1.0, 0.98, 0.525) 958marigold = Color(0.988, 0.753, 0.024) 959marine = Color(0.016, 0.18, 0.376) 960marine_blue = Color(0.004, 0.22, 0.416) 961maroon = Color(0.396, 0.0, 0.129) 962mauve = Color(0.682, 0.443, 0.506) 963medium_blue = Color(0.173, 0.435, 0.733) 964medium_brown = Color(0.498, 0.318, 0.071) 965medium_green = Color(0.224, 0.678, 0.282) 966medium_grey = Color(0.49, 0.498, 0.486) 967medium_gray = Color(0.49, 0.498, 0.486) 968medium_pink = Color(0.953, 0.38, 0.588) 969medium_purple = Color(0.62, 0.263, 0.635) 970melon = Color(1.0, 0.471, 0.333) 971merlot = Color(0.451, 0.0, 0.224) 972metallic_blue = Color(0.31, 0.451, 0.557) 973mid_blue = Color(0.153, 0.416, 0.702) 974mid_green = Color(0.314, 0.655, 0.278) 975midnight = Color(0.012, 0.004, 0.176) 976midnight_blue = Color(0.008, 0.0, 0.208) 977midnight_purple = Color(0.157, 0.004, 0.216) 978military_green = Color(0.4, 0.486, 0.243) 979milk_chocolate = Color(0.498, 0.306, 0.118) 980mint = Color(0.624, 0.996, 0.69) 981mint_green = Color(0.561, 1.0, 0.624) 982minty_green = Color(0.043, 0.969, 0.49) 983mocha = Color(0.616, 0.463, 0.318) 984moss = Color(0.463, 0.6, 0.345) 985moss_green = Color(0.396, 0.545, 0.22) 986mossy_green = Color(0.388, 0.545, 0.153) 987mud = Color(0.451, 0.361, 0.071) 988mud_brown = Color(0.376, 0.275, 0.059) 989mud_green = Color(0.376, 0.4, 0.008) 990muddy_brown = Color(0.533, 0.408, 0.024) 991muddy_green = Color(0.396, 0.455, 0.196) 992muddy_yellow = Color(0.749, 0.675, 0.02) 993mulberry = Color(0.573, 0.039, 0.306) 994murky_green = Color(0.424, 0.478, 0.055) 995mushroom = Color(0.729, 0.62, 0.533) 996mustard = Color(0.808, 0.702, 0.004) 997mustard_brown = Color(0.675, 0.494, 0.016) 998mustard_green = Color(0.659, 0.71, 0.016) 999mustard_yellow = Color(0.824, 0.741, 0.039) 1000muted_blue = Color(0.231, 0.443, 0.624) 1001muted_green = Color(0.373, 0.627, 0.322) 1002muted_pink = Color(0.82, 0.463, 0.561) 1003muted_purple = Color(0.502, 0.357, 0.529) 1004nasty_green = Color(0.439, 0.698, 0.247) 1005navy = Color(0.004, 0.082, 0.243) 1006navy_blue = Color(0.0, 0.067, 0.275) 1007navy_green = Color(0.208, 0.325, 0.039) 1008neon_blue = Color(0.016, 0.851, 1.0) 1009neon_green = Color(0.047, 1.0, 0.047) 1010neon_pink = Color(0.996, 0.004, 0.604) 1011neon_purple = Color(0.737, 0.075, 0.996) 1012neon_red = Color(1.0, 0.027, 0.227) 1013neon_yellow = Color(0.812, 1.0, 0.016) 1014nice_blue = Color(0.063, 0.478, 0.69) 1015night_blue = Color(0.016, 0.012, 0.282) 1016ocean = Color(0.004, 0.482, 0.573) 1017ocean_blue = Color(0.012, 0.443, 0.612) 1018ocean_green = Color(0.239, 0.6, 0.451) 1019ocher = Color(0.749, 0.608, 0.047) 1020ochre = Color(0.749, 0.565, 0.02) 1021ocre = Color(0.776, 0.612, 0.016) 1022off_blue = Color(0.337, 0.518, 0.682) 1023off_green = Color(0.42, 0.639, 0.325) 1024off_white = Color(1.0, 1.0, 0.894) 1025off_yellow = Color(0.945, 0.953, 0.247) 1026old_pink = Color(0.78, 0.475, 0.525) 1027old_rose = Color(0.784, 0.498, 0.537) 1028olive = Color(0.431, 0.459, 0.055) 1029olive_brown = Color(0.392, 0.329, 0.012) 1030olive_drab = Color(0.435, 0.463, 0.196) 1031olive_green = Color(0.404, 0.478, 0.016) 1032olive_yellow = Color(0.761, 0.718, 0.035) 1033orange = Color(0.976, 0.451, 0.024) 1034orange_brown = Color(0.745, 0.392, 0.0) 1035orange_pink = Color(1.0, 0.435, 0.322) 1036orange_red = Color(0.992, 0.255, 0.118) 1037orange_yellow = Color(1.0, 0.678, 0.004) 1038orangeish = Color(0.992, 0.553, 0.286) 1039orangered = Color(0.996, 0.259, 0.059) 1040orangey_brown = Color(0.694, 0.376, 0.008) 1041orangey_red = Color(0.98, 0.259, 0.141) 1042orangey_yellow = Color(0.992, 0.725, 0.082) 1043orangish = Color(0.988, 0.51, 0.29) 1044orangish_brown = Color(0.698, 0.373, 0.012) 1045orangish_red = Color(0.957, 0.212, 0.02) 1046orchid = Color(0.784, 0.459, 0.769) 1047pale = Color(1.0, 0.976, 0.816) 1048pale_aqua = Color(0.722, 1.0, 0.922) 1049pale_blue = Color(0.816, 0.996, 0.996) 1050pale_brown = Color(0.694, 0.569, 0.431) 1051pale_cyan = Color(0.718, 1.0, 0.98) 1052pale_gold = Color(0.992, 0.871, 0.424) 1053pale_green = Color(0.78, 0.992, 0.71) 1054pale_grey = Color(0.992, 0.992, 0.996) 1055pale_gray = Color(0.992, 0.992, 0.996) 1056pale_lavender = Color(0.933, 0.812, 0.996) 1057pale_light_green = Color(0.694, 0.988, 0.6) 1058pale_lilac = Color(0.894, 0.796, 1.0) 1059pale_lime = Color(0.745, 0.992, 0.451) 1060pale_lime_green = Color(0.694, 1.0, 0.396) 1061pale_magenta = Color(0.843, 0.404, 0.678) 1062pale_mauve = Color(0.996, 0.816, 0.988) 1063pale_olive = Color(0.725, 0.8, 0.506) 1064pale_olive_green = Color(0.694, 0.824, 0.482) 1065pale_orange = Color(1.0, 0.655, 0.337) 1066pale_peach = Color(1.0, 0.898, 0.678) 1067pale_pink = Color(1.0, 0.812, 0.863) 1068pale_purple = Color(0.718, 0.565, 0.831) 1069pale_red = Color(0.851, 0.329, 0.302) 1070pale_rose = Color(0.992, 0.757, 0.773) 1071pale_salmon = Color(1.0, 0.694, 0.604) 1072pale_sky_blue = Color(0.741, 0.965, 0.996) 1073pale_teal = Color(0.51, 0.796, 0.698) 1074pale_turquoise = Color(0.647, 0.984, 0.835) 1075pale_violet = Color(0.808, 0.682, 0.98) 1076pale_yellow = Color(1.0, 1.0, 0.518) 1077parchment = Color(0.996, 0.988, 0.686) 1078pastel_blue = Color(0.635, 0.749, 0.996) 1079pastel_green = Color(0.69, 1.0, 0.616) 1080pastel_orange = Color(1.0, 0.588, 0.31) 1081pastel_pink = Color(1.0, 0.729, 0.804) 1082pastel_purple = Color(0.792, 0.627, 1.0) 1083pastel_red = Color(0.859, 0.345, 0.337) 1084pastel_yellow = Color(1.0, 0.996, 0.443) 1085pea = Color(0.643, 0.749, 0.125) 1086pea_green = Color(0.557, 0.671, 0.071) 1087pea_soup = Color(0.573, 0.6, 0.004) 1088pea_soup_green = Color(0.58, 0.651, 0.09) 1089peach = Color(1.0, 0.69, 0.486) 1090peachy_pink = Color(1.0, 0.604, 0.541) 1091peacock_blue = Color(0.004, 0.404, 0.584) 1092pear = Color(0.796, 0.973, 0.373) 1093periwinkle = Color(0.557, 0.51, 0.996) 1094periwinkle_blue = Color(0.561, 0.6, 0.984) 1095perrywinkle = Color(0.561, 0.549, 0.906) 1096petrol = Color(0.0, 0.373, 0.416) 1097pig_pink = Color(0.906, 0.557, 0.647) 1098pine = Color(0.169, 0.365, 0.204) 1099pine_green = Color(0.039, 0.282, 0.118) 1100pink = Color(1.0, 0.506, 0.753) 1101pink_purple = Color(0.859, 0.294, 0.855) 1102pink_red = Color(0.961, 0.02, 0.31) 1103pink_purple = Color(0.937, 0.114, 0.906) 1104pinkish = Color(0.831, 0.416, 0.494) 1105pinkish_brown = Color(0.694, 0.447, 0.38) 1106pinkish_grey = Color(0.784, 0.675, 0.663) 1107pinkish_gray = Color(0.784, 0.675, 0.663) 1108pinkish_orange = Color(1.0, 0.447, 0.298) 1109pinkish_purple = Color(0.839, 0.282, 0.843) 1110pinkish_red = Color(0.945, 0.047, 0.271) 1111pinkish_tan = Color(0.851, 0.608, 0.51) 1112pinky = Color(0.988, 0.525, 0.667) 1113pinky_purple = Color(0.788, 0.298, 0.745) 1114pinky_red = Color(0.988, 0.149, 0.278) 1115piss_yellow = Color(0.867, 0.839, 0.094) 1116pistachio = Color(0.753, 0.98, 0.545) 1117plum = Color(0.345, 0.059, 0.255) 1118plum_purple = Color(0.306, 0.02, 0.314) 1119poison_green = Color(0.251, 0.992, 0.078) 1120poo = Color(0.561, 0.451, 0.012) 1121poo_brown = Color(0.533, 0.373, 0.004) 1122poop = Color(0.498, 0.369, 0.0) 1123poop_brown = Color(0.478, 0.349, 0.004) 1124poop_green = Color(0.435, 0.486, 0.0) 1125powder_blue = Color(0.694, 0.82, 0.988) 1126powder_pink = Color(1.0, 0.698, 0.816) 1127primary_blue = Color(0.031, 0.016, 0.976) 1128prussian_blue = Color(0.0, 0.271, 0.467) 1129puce = Color(0.647, 0.494, 0.322) 1130puke = Color(0.647, 0.647, 0.008) 1131puke_brown = Color(0.58, 0.467, 0.024) 1132puke_green = Color(0.604, 0.682, 0.027) 1133puke_yellow = Color(0.761, 0.745, 0.055) 1134pumpkin = Color(0.882, 0.467, 0.004) 1135pumpkin_orange = Color(0.984, 0.49, 0.027) 1136pure_blue = Color(0.008, 0.012, 0.886) 1137purple = Color(0.494, 0.118, 0.612) 1138purple_blue = Color(0.388, 0.176, 0.914) 1139purple_brown = Color(0.404, 0.227, 0.247) 1140purple_grey = Color(0.525, 0.435, 0.522) 1141purple_gray = Color(0.525, 0.435, 0.522) 1142purple_pink = Color(0.878, 0.247, 0.847) 1143purple_red = Color(0.6, 0.004, 0.278) 1144purple_blue = Color(0.365, 0.129, 0.816) 1145purple_pink = Color(0.843, 0.145, 0.871) 1146purpleish = Color(0.596, 0.337, 0.553) 1147purpleish_blue = Color(0.38, 0.251, 0.937) 1148purpleish_pink = Color(0.875, 0.306, 0.784) 1149purpley = Color(0.529, 0.337, 0.894) 1150purpley_blue = Color(0.373, 0.204, 0.906) 1151purpley_grey = Color(0.58, 0.494, 0.58) 1152purpley_gray = Color(0.58, 0.494, 0.58) 1153purpley_pink = Color(0.784, 0.235, 0.725) 1154purplish = Color(0.58, 0.337, 0.549) 1155purplish_blue = Color(0.376, 0.118, 0.976) 1156purplish_brown = Color(0.42, 0.259, 0.278) 1157purplish_grey = Color(0.478, 0.408, 0.498) 1158purplisth_gray = Color(0.478, 0.408, 0.498) 1159purplish_pink = Color(0.808, 0.365, 0.682) 1160purplish_red = Color(0.69, 0.02, 0.294) 1161purply = Color(0.596, 0.247, 0.698) 1162purply_blue = Color(0.4, 0.102, 0.933) 1163purply_pink = Color(0.941, 0.459, 0.902) 1164putty = Color(0.745, 0.682, 0.541) 1165racing_green = Color(0.004, 0.275, 0.0) 1166radioactive_green = Color(0.173, 0.98, 0.122) 1167raspberry = Color(0.69, 0.004, 0.286) 1168raw_sienna = Color(0.604, 0.384, 0.0) 1169raw_umber = Color(0.655, 0.369, 0.035) 1170really_light_blue = Color(0.831, 1.0, 1.0) 1171red = Color(0.898, 0.0, 0.0) 1172red_brown = Color(0.545, 0.18, 0.086) 1173red_orange = Color(0.992, 0.235, 0.024) 1174red_pink = Color(0.98, 0.165, 0.333) 1175red_purple = Color(0.51, 0.027, 0.278) 1176red_violet = Color(0.62, 0.004, 0.408) 1177red_wine = Color(0.549, 0.0, 0.204) 1178reddish = Color(0.769, 0.259, 0.251) 1179reddish_brown = Color(0.498, 0.169, 0.039) 1180reddish_grey = Color(0.6, 0.459, 0.439) 1181reddish_gray = Color(0.6, 0.459, 0.439) 1182reddish_orange = Color(0.973, 0.282, 0.11) 1183reddish_pink = Color(0.996, 0.173, 0.329) 1184reddish_purple = Color(0.569, 0.035, 0.318) 1185reddy_brown = Color(0.431, 0.063, 0.02) 1186rich_blue = Color(0.008, 0.106, 0.976) 1187rich_purple = Color(0.447, 0.0, 0.345) 1188robin_egg_blue = Color(0.541, 0.945, 0.996) 1189robins_egg = Color(0.427, 0.929, 0.992) 1190robins_egg_blue = Color(0.596, 0.937, 0.976) 1191rosa = Color(0.996, 0.525, 0.643) 1192rose = Color(0.812, 0.384, 0.459) 1193rose_pink = Color(0.969, 0.529, 0.604) 1194rose_red = Color(0.745, 0.004, 0.235) 1195rosy_pink = Color(0.965, 0.408, 0.557) 1196rouge = Color(0.671, 0.071, 0.224) 1197royal = Color(0.047, 0.09, 0.576) 1198royal_blue = Color(0.02, 0.016, 0.667) 1199royal_purple = Color(0.294, 0.0, 0.431) 1200ruby = Color(0.792, 0.004, 0.278) 1201russet = Color(0.631, 0.224, 0.02) 1202rust = Color(0.659, 0.235, 0.035) 1203rust_brown = Color(0.545, 0.192, 0.012) 1204rust_orange = Color(0.769, 0.333, 0.031) 1205rust_red = Color(0.667, 0.153, 0.016) 1206rusty_orange = Color(0.804, 0.349, 0.035) 1207rusty_red = Color(0.686, 0.184, 0.051) 1208saffron = Color(0.996, 0.698, 0.035) 1209sage = Color(0.529, 0.682, 0.451) 1210sage_green = Color(0.533, 0.702, 0.471) 1211salmon = Color(1.0, 0.475, 0.424) 1212salmon_pink = Color(0.996, 0.482, 0.486) 1213sand = Color(0.886, 0.792, 0.463) 1214sand_brown = Color(0.796, 0.647, 0.376) 1215sand_yellow = Color(0.988, 0.882, 0.4) 1216sandstone = Color(0.788, 0.682, 0.455) 1217sandy = Color(0.945, 0.855, 0.478) 1218sandy_brown = Color(0.769, 0.651, 0.38) 1219sandy_yellow = Color(0.992, 0.933, 0.451) 1220sap_green = Color(0.361, 0.545, 0.082) 1221sapphire = Color(0.129, 0.22, 0.671) 1222scarlet = Color(0.745, 0.004, 0.098) 1223sea = Color(0.235, 0.6, 0.573) 1224sea_blue = Color(0.016, 0.455, 0.584) 1225sea_green = Color(0.325, 0.988, 0.631) 1226seafoam = Color(0.502, 0.976, 0.678) 1227seafoam_blue = Color(0.471, 0.82, 0.714) 1228seafoam_green = Color(0.478, 0.976, 0.671) 1229seaweed = Color(0.094, 0.82, 0.482) 1230seaweed_green = Color(0.208, 0.678, 0.42) 1231sepia = Color(0.596, 0.369, 0.169) 1232shamrock = Color(0.004, 0.706, 0.298) 1233shamrock_green = Color(0.008, 0.757, 0.302) 1234shit = Color(0.498, 0.373, 0.0) 1235shit_brown = Color(0.482, 0.345, 0.016) 1236shit_green = Color(0.459, 0.502, 0.0) 1237shocking_pink = Color(0.996, 0.008, 0.635) 1238sick_green = Color(0.616, 0.725, 0.173) 1239sickly_green = Color(0.58, 0.698, 0.11) 1240sickly_yellow = Color(0.816, 0.894, 0.161) 1241sienna = Color(0.663, 0.337, 0.118) 1242silver = Color(0.773, 0.788, 0.78) 1243sky = Color(0.51, 0.792, 0.988) 1244sky_blue = Color(0.459, 0.733, 0.992) 1245slate = Color(0.318, 0.396, 0.447) 1246slate_blue = Color(0.357, 0.486, 0.6) 1247slate_green = Color(0.396, 0.553, 0.427) 1248slate_grey = Color(0.349, 0.396, 0.427) 1249slate_gray = Color(0.349, 0.396, 0.427) 1250slime_green = Color(0.6, 0.8, 0.016) 1251snot = Color(0.675, 0.733, 0.051) 1252snot_green = Color(0.616, 0.757, 0.0) 1253soft_blue = Color(0.392, 0.533, 0.918) 1254soft_green = Color(0.435, 0.761, 0.463) 1255soft_pink = Color(0.992, 0.69, 0.753) 1256soft_purple = Color(0.651, 0.435, 0.71) 1257spearmint = Color(0.118, 0.973, 0.463) 1258spring_green = Color(0.663, 0.976, 0.443) 1259spruce = Color(0.039, 0.373, 0.22) 1260squash = Color(0.949, 0.671, 0.082) 1261steel = Color(0.451, 0.522, 0.584) 1262steel_blue = Color(0.353, 0.49, 0.604) 1263steel_grey = Color(0.435, 0.51, 0.541) 1264steel_gray = Color(0.435, 0.51, 0.541) 1265stone = Color(0.678, 0.647, 0.529) 1266stormy_blue = Color(0.314, 0.482, 0.612) 1267straw = Color(0.988, 0.965, 0.475) 1268strawberry = Color(0.984, 0.161, 0.263) 1269strong_blue = Color(0.047, 0.024, 0.969) 1270strong_pink = Color(1.0, 0.027, 0.537) 1271sun_yellow = Color(1.0, 0.875, 0.133) 1272sunflower = Color(1.0, 0.773, 0.071) 1273sunflower_yellow = Color(1.0, 0.855, 0.012) 1274sunny_yellow = Color(1.0, 0.976, 0.09) 1275sunshine_yellow = Color(1.0, 0.992, 0.216) 1276swamp = Color(0.412, 0.514, 0.224) 1277swamp_green = Color(0.455, 0.522, 0.0) 1278tan_ = Color(0.82, 0.698, 0.435) # tan is a reserved word 1279tan_brown = Color(0.671, 0.494, 0.298) 1280tan_green = Color(0.663, 0.745, 0.439) 1281tangerine = Color(1.0, 0.58, 0.031) 1282taupe = Color(0.725, 0.635, 0.506) 1283tea = Color(0.396, 0.671, 0.486) 1284tea_green = Color(0.741, 0.973, 0.639) 1285teal = Color(0.008, 0.576, 0.525) 1286teal_blue = Color(0.004, 0.533, 0.624) 1287teal_green = Color(0.145, 0.639, 0.435) 1288tealish = Color(0.141, 0.737, 0.659) 1289tealish_green = Color(0.047, 0.863, 0.451) 1290terra_cotta = Color(0.788, 0.392, 0.231) 1291terracota = Color(0.796, 0.408, 0.263) 1292terracotta = Color(0.792, 0.4, 0.255) 1293tiffany_blue = Color(0.482, 0.949, 0.855) 1294tomato = Color(0.937, 0.251, 0.149) 1295tomato_red = Color(0.925, 0.176, 0.004) 1296topaz = Color(0.075, 0.733, 0.686) 1297toupe = Color(0.78, 0.675, 0.49) 1298toxic_green = Color(0.38, 0.871, 0.165) 1299tree_green = Color(0.165, 0.494, 0.098) 1300true_blue = Color(0.004, 0.059, 0.8) 1301true_green = Color(0.031, 0.58, 0.016) 1302turquoise = Color(0.024, 0.761, 0.675) 1303turquoise_blue = Color(0.024, 0.694, 0.769) 1304turquoise_green = Color(0.016, 0.957, 0.537) 1305turtle_green = Color(0.459, 0.722, 0.31) 1306twilight = Color(0.306, 0.318, 0.545) 1307twilight_blue = Color(0.039, 0.263, 0.478) 1308ugly_blue = Color(0.192, 0.4, 0.541) 1309ugly_brown = Color(0.49, 0.443, 0.012) 1310ugly_green = Color(0.478, 0.592, 0.012) 1311ugly_pink = Color(0.804, 0.459, 0.518) 1312ugly_purple = Color(0.643, 0.259, 0.627) 1313ugly_yellow = Color(0.816, 0.757, 0.004) 1314ultramarine = Color(0.125, 0.0, 0.694) 1315ultramarine_blue = Color(0.094, 0.02, 0.859) 1316umber = Color(0.698, 0.392, 0.0) 1317velvet = Color(0.459, 0.031, 0.318) 1318vermillion = Color(0.957, 0.196, 0.047) 1319very_dark_blue = Color(0.0, 0.004, 0.2) 1320very_dark_brown = Color(0.114, 0.008, 0.0) 1321very_dark_green = Color(0.024, 0.18, 0.012) 1322very_dark_purple = Color(0.165, 0.004, 0.204) 1323very_light_blue = Color(0.835, 1.0, 1.0) 1324very_light_brown = Color(0.827, 0.714, 0.514) 1325very_light_green = Color(0.82, 1.0, 0.741) 1326very_light_pink = Color(1.0, 0.957, 0.949) 1327very_light_purple = Color(0.965, 0.808, 0.988) 1328very_pale_blue = Color(0.839, 1.0, 0.996) 1329very_pale_green = Color(0.812, 0.992, 0.737) 1330vibrant_blue = Color(0.012, 0.224, 0.973) 1331vibrant_green = Color(0.039, 0.867, 0.031) 1332vibrant_purple = Color(0.678, 0.012, 0.871) 1333violet = Color(0.604, 0.055, 0.918) 1334violet_blue = Color(0.318, 0.039, 0.788) 1335violet_pink = Color(0.984, 0.373, 0.988) 1336violet_red = Color(0.647, 0.0, 0.333) 1337viridian = Color(0.118, 0.569, 0.404) 1338vivid_blue = Color(0.082, 0.18, 1.0) 1339vivid_green = Color(0.184, 0.937, 0.063) 1340vivid_purple = Color(0.6, 0.0, 0.98) 1341vomit = Color(0.635, 0.643, 0.082) 1342vomit_green = Color(0.537, 0.635, 0.012) 1343vomit_yellow = Color(0.78, 0.757, 0.047) 1344warm_blue = Color(0.294, 0.341, 0.859) 1345warm_brown = Color(0.588, 0.306, 0.008) 1346warm_grey = Color(0.592, 0.541, 0.518) 1347warm_gray = Color(0.592, 0.541, 0.518) 1348warm_pink = Color(0.984, 0.333, 0.506) 1349warm_purple = Color(0.584, 0.18, 0.561) 1350washed_out_green = Color(0.737, 0.961, 0.651) 1351water_blue = Color(0.055, 0.529, 0.8) 1352watermelon = Color(0.992, 0.275, 0.349) 1353weird_green = Color(0.227, 0.898, 0.498) 1354wheat = Color(0.984, 0.867, 0.494) 1355white = Color(1.0, 1.0, 1.0) 1356windows_blue = Color(0.216, 0.471, 0.749) 1357wine = Color(0.502, 0.004, 0.247) 1358wine_red = Color(0.482, 0.012, 0.137) 1359wintergreen = Color(0.125, 0.976, 0.525) 1360wisteria = Color(0.659, 0.49, 0.761) 1361yellow = Color(1.0, 1.0, 0.078) 1362yellow_brown = Color(0.718, 0.58, 0.0) 1363yellow_green = Color(0.753, 0.984, 0.176) 1364yellow_ochre = Color(0.796, 0.616, 0.024) 1365yellow_orange = Color(0.988, 0.69, 0.004) 1366yellow_tan = Color(1.0, 0.89, 0.431) 1367yellow_green = Color(0.784, 0.992, 0.239) 1368yellowgreen = Color(0.733, 0.976, 0.059) 1369yellowish = Color(0.98, 0.933, 0.4) 1370yellowish_brown = Color(0.608, 0.478, 0.004) 1371yellowish_green = Color(0.69, 0.867, 0.086) 1372yellowish_orange = Color(1.0, 0.671, 0.059) 1373yellowish_tan = Color(0.988, 0.988, 0.506) 1374yellowy_brown = Color(0.682, 0.545, 0.047) 1375yellowy_green = Color(0.749, 0.945, 0.157)
25def change_hue(color: 'Color', delta: float) -> 'Color': 26 """Changes the hue of a color by a specified delta value. 27 28 Args: 29 color: The Color object to modify. 30 delta: The amount to adjust the hue value (between 0.0 and 1.0). 31 Positive values increase hue, negative values decrease it. 32 33 Returns: 34 A new Color instance with the modified hue value. 35 """ 36 r, g, b, a = color.rgba 37 hls = colorsys.rgb_to_hls(r, g, b) 38 r, g, b = colorsys.hls_to_rgb(hls[0] + delta, hls[1], hls[2]) 39 return Color(r, g, b, a)
Changes the hue of a color by a specified delta value.
Arguments:
- color: The Color object to modify.
- delta: The amount to adjust the hue value (between 0.0 and 1.0). Positive values increase hue, negative values decrease it.
Returns:
A new Color instance with the modified hue value.
42def change_lightness(color: 'Color', delta: float) -> 'Color': 43 """Changes the lightness of a color by a specified delta value. 44 45 Args: 46 color: The Color object to modify. 47 delta: The amount to adjust the lightness value (between -1.0 and 1.0). 48 Positive values increase lightness, negative values decrease it. 49 50 Returns: 51 A new Color instance with the modified lightness value. 52 """ 53 r, g, b, a = color.rgba 54 hls = colorsys.rgb_to_hls(r, g, b) 55 r, g, b = colorsys.hls_to_rgb(hls[0], hls[1] + delta, hls[2]) 56 return Color(r, g, b, a)
Changes the lightness of a color by a specified delta value.
Arguments:
- color: The Color object to modify.
- delta: The amount to adjust the lightness value (between -1.0 and 1.0). Positive values increase lightness, negative values decrease it.
Returns:
A new Color instance with the modified lightness value.
59def change_saturation(color: 'Color', delta: float) -> 'Color': 60 """Changes the saturation of a color by a specified delta value. 61 62 Args: 63 color: The Color object to modify. 64 delta: The amount to adjust the saturation value (between -1.0 and 1.0). 65 Positive values increase saturation, negative values decrease it. 66 67 Returns: 68 A new Color instance with the modified saturation value. 69 """ 70 r, g, b, a = color.rgba 71 hls = colorsys.rgb_to_hls(r, g, b) 72 r, g, b = colorsys.hls_to_rgb(hls[0], hls[1], hls[2] + delta) 73 return Color(r, g, b, a)
Changes the saturation of a color by a specified delta value.
Arguments:
- color: The Color object to modify.
- delta: The amount to adjust the saturation value (between -1.0 and 1.0). Positive values increase saturation, negative values decrease it.
Returns:
A new Color instance with the modified saturation value.
104def hex_to_rgb(hexa): 105 """Convert hex to RGB.""" 106 return tuple([int(hexa[i : i + 2], 16) for i in [0, 2, 4]])
Convert hex to RGB.
Convert RGB to hex.
116@dataclass 117class Color: 118 """A class representing an RGB or RGBA color. 119 120 This class represents a color in RGB or RGBA color space. The default values 121 for the components are normalized between 0.0 and 1.0. Values outside this range 122 are automatically converted from the 0-255 range. 123 124 Attributes: 125 red: The red component of the color (0.0 to 1.0). 126 green: The green component of the color (0.0 to 1.0). 127 blue: The blue component of the color (0.0 to 1.0). 128 alpha: The alpha (transparency) component (0.0 to 1.0), default is 1. 129 space: The color space, default is "rgb". 130 131 Examples: 132 >>> red = Color(1.0, 0.0, 0.0) 133 >>> transparent_blue = Color(0.0, 0.0, 1.0, 0.5) 134 >>> rgb255 = Color(255, 0, 128) # Will be automatically normalized 135 """ 136 red: int = 0 137 green: int = 0 138 blue: int = 0 139 alpha: int = 1 140 space: ColorSpace = "rgb" # for future use 141 142 def __post_init__(self): 143 """Post-initialization to ensure color values are in the correct range.""" 144 r, g, b = self.red, self.green, self.blue 145 if r < 0 or r > 1 or g < 0 or g > 1 or b < 0 or b > 1: 146 self.red = r / 255 147 self.green = g / 255 148 self.blue = b / 255 149 if self.alpha < 0 or self.alpha > 1: 150 self.alpha = self.alpha / 255 151 common_properties(self) 152 153 def __str__(self): 154 return f"Color({self.red}, {self.green}, {self.blue})" 155 156 def __repr__(self): 157 return f"Color({self.red}, {self.green}, {self.blue})" 158 159 def copy(self): 160 return Color(self.red, self.green, self.blue, self.alpha) 161 162 @property 163 def __key__(self): 164 return (self.red, self.green, self.blue) 165 166 def __hash__(self): 167 return hash(self.__key__) 168 169 @property 170 def name(self): 171 # search for the color in the named colors 172 pass 173 174 def __eq__(self, other): 175 if isinstance(other, Color): 176 return self.__key__ == other.__key__ 177 else: 178 return False 179 180 @property 181 def rgb(self): 182 return (self.red, self.green, self.blue) 183 184 @property 185 def rgba(self): 186 return (self.red, self.green, self.blue, self.alpha) 187 188 @property 189 def rgb255(self): 190 r, g, b = self.rgb 191 if r > 1 or g > 1 or b > 1: 192 return (r, g, b) 193 return tuple(round(i * 255) for i in self.rgb) 194 195 @property 196 def rgba255(self): 197 return tuple(round(i * 255) for i in self.rgba)
A class representing an RGB or RGBA color.
This class represents a color in RGB or RGBA color space. The default values for the components are normalized between 0.0 and 1.0. Values outside this range are automatically converted from the 0-255 range.
Attributes:
- red: The red component of the color (0.0 to 1.0).
- green: The green component of the color (0.0 to 1.0).
- blue: The blue component of the color (0.0 to 1.0).
- alpha: The alpha (transparency) component (0.0 to 1.0), default is 1.
- space: The color space, default is "rgb".
Examples:
>>> red = Color(1.0, 0.0, 0.0) >>> transparent_blue = Color(0.0, 0.0, 1.0, 0.5) >>> rgb255 = Color(255, 0, 128) # Will be automatically normalized
200def map_color(r:float, g:float, b:float, r_max:float, g_max:float, 201 b_max:float) -> Color: 202 """Map RGB values to a range of 0-255.""" 203 i_range = range(256) 204 r_range = np.arange(0, r_max, r_max/256) 205 g_range = np.arange(0, g_max, g_max/256) 206 b_range = np.arange(0, b_max, b_max/256) 207 208 r_ = np.interp(r, r_range, i_range) 209 g_ = np.interp(g, g_range, i_range) 210 b_ = np.interp(b, b_range, i_range) 211 212 return Color(r_, g_, b_)
Map RGB values to a range of 0-255.
214def blend(color1: Color, percent: int, color2: Color): 215 """percent% of color1 and (100-percent)% of color2 216 blended together to create a new color.""" 217 percent = percent / 100 218 r1, g1, b1 = color1 219 r2, g2, b2 = color2 220 221 r_blend = r1 * percent + r2 * (1 - percent) 222 g_blend = g1 * percent + g2 * (1 - percent) 223 b_blend = b1 * percent + b2 * (1 - percent) 224 225 return Color(r_blend, g_blend, b_blend)
percent% of color1 and (100-percent)% of color2 blended together to create a new color.
228def get_color(value): 229 """ 230 if value is [r, g, b] return Color(r, g, b) 231 if value is a string return Color(value) 232 if value is a Color return value 233 """ 234 if isinstance(value, Color): 235 return value 236 elif isinstance(value, str): 237 return Color(value) 238 elif isinstance(value, (list, tuple)): 239 return Color(*value) 240 else: 241 raise TypeError("Invalid color value")
if value is [r, g, b] return Color(r, g, b) if value is a string return Color(value) if value is a Color return value
279def rgb2hex(rgb): 280 """Convert an RGB tuple to a hex color value.""" 281 r, g, b = rgb 282 return f"#{r:02x}{g:02x}{b:02x}"
Convert an RGB tuple to a hex color value.
285def hex2rgb(hex_val): 286 """Convert a hex color value to an RGB tuple.""" 287 hex_val = hex_val.strip("#") 288 return tuple(round(int(hex_val[i : i + 2], 16) / 255, 3) for i in (0, 2, 4))
Convert a hex color value to an RGB tuple.
291def cmyk2rgb(c, m, y, k): 292 """Convert a CMYK color value to an RGB tuple.""" 293 r = 1 - min(1, c * (1 - k) + k) 294 g = 1 - min(1, m * (1 - k) + k) 295 b = 1 - min(1, y * (1 - k) + k) 296 return (r, g, b)
Convert a CMYK color value to an RGB tuple.
299def random_color(): 300 """Return a random color.""" 301 return Color(random(), random(), random())
Return a random color.
304@dataclass 305class LinearGradient: 306 """A class representing a linear gradient. 307 308 This class defines a linear gradient between two points with specified colors. 309 310 Attributes: 311 x1: The x-coordinate of the starting point. 312 y1: The y-coordinate of the starting point. 313 x2: The x-coordinate of the ending point. 314 y2: The y-coordinate of the ending point. 315 colors: A sequence of Color objects defining the gradient colors. 316 positions: A sequence of Point objects defining the gradient positions. 317 extend: Whether to extend the gradient beyond its endpoints. 318 319 Examples: 320 >>> from simetri.graphics.common import Point 321 >>> gradient = LinearGradient(0, 0, 100, 100, 322 ... [Color(1, 0, 0), Color(0, 0, 1)], 323 ... [Point(0, 0), Point(100, 100)]) 324 """ 325 x1: float = 0.0 326 y1: float = 0.0 327 x2: float = 0.0 328 y2: float = 0.0 329 colors: Sequence[Color] = None 330 positions: Sequence[Point] = None 331 extend: bool = False 332 333 def __post_init__(self): 334 self.type = Types.GRADIENT 335 self.subtype = Types.LINEAR 336 common_properties(self)
A class representing a linear gradient.
This class defines a linear gradient between two points with specified colors.
Attributes:
- x1: The x-coordinate of the starting point.
- y1: The y-coordinate of the starting point.
- x2: The x-coordinate of the ending point.
- y2: The y-coordinate of the ending point.
- colors: A sequence of Color objects defining the gradient colors.
- positions: A sequence of Point objects defining the gradient positions.
- extend: Whether to extend the gradient beyond its endpoints.
Examples:
>>> from simetri.graphics.common import Point >>> gradient = LinearGradient(0, 0, 100, 100, ... [Color(1, 0, 0), Color(0, 0, 1)], ... [Point(0, 0), Point(100, 100)])
339@dataclass 340class RadialGradient: 341 """A class representing a radial gradient. 342 343 This class defines a radial gradient that radiates outward from a center point. 344 345 Attributes: 346 x: The x-coordinate of the center point. 347 y: The y-coordinate of the center point. 348 radius: The radius of the gradient. 349 colors: A sequence of Color objects defining the gradient colors. 350 positions: A sequence of Point objects defining the gradient positions. 351 extend: Whether to extend the gradient beyond its defined radius. 352 353 Examples: 354 >>> from simetri.graphics.common import Point 355 >>> gradient = RadialGradient(50, 50, 30, 356 ... [Color(1, 1, 1), Color(0, 0, 0)], 357 ... [Point(50, 50), Point(80, 50)]) 358 """ 359 x: float = 0.0 360 y: float = 0.0 361 radius: float = 0.0 362 colors: Sequence[Color] = None 363 positions: Sequence[Point] = None 364 extend: bool = False 365 366 def __post_init__(self): 367 self.type = Types.GRADIENT 368 self.subtype = Types.RADIAL 369 common_properties(self)
A class representing a radial gradient.
This class defines a radial gradient that radiates outward from a center point.
Attributes:
- x: The x-coordinate of the center point.
- y: The y-coordinate of the center point.
- radius: The radius of the gradient.
- colors: A sequence of Color objects defining the gradient colors.
- positions: A sequence of Point objects defining the gradient positions.
- extend: Whether to extend the gradient beyond its defined radius.
Examples:
>>> from simetri.graphics.common import Point >>> gradient = RadialGradient(50, 50, 30, ... [Color(1, 1, 1), Color(0, 0, 0)], ... [Point(50, 50), Point(80, 50)])