Colors
Color type, functions to produce colors, and constants for important colors.
- class Color[source]
Represents a color. A color also has a degree of opacity, from completely transparent (like the color transparent) to completely opaque (like the color red).
- hsl_color(hue: float, saturation: float, lightness: float, opacity: float = 1.0) Color [source]
Returns a color with the provided hue (H), saturation (S), lightness (L) and a certain degree of opacity (alpha, A).
- Parameters:
hue – hue of the color [0-360]
saturation – saturation of the color [0-1]
lightness – the amount of white or black applied [0-1]. Fully saturated colors have a lightness value of 1/2.
opacity – opacity (alpha) of the color, where 0 means fully transparent and 1 fully opaque. By default, all colors are fully opaque.
- Returns:
a color with the provided HSLA components
- hsv_color(hue: float, saturation: float, value: float, opacity: float = 1.0) Color [source]
Returns a color with the provided hue (H), saturation (S), value (V) and a certain degree of opacity (alpha, A).
- Parameters:
hue – hue of the color [0-360]
saturation – saturation of the color [0-1]
value – the amount of light that is applied [0-1]
opacity – opacity (alpha) of the color, where 0 means fully transparent and 1 fully opaque. By default, all colors are fully opaque.
- Returns:
a color with the provided HSVA components.
- rgb_color(red: int, green: int, blue: int, opacity: float = 1.0) Color [source]
Returns a color with the provided components for red (R), green (G) and blue (B) and a certain degree of opacity (alpha, A).
- Parameters:
red – red component [0-255]
green – green component [0-255]
blue – blue component [0-255]
opacity – opacity (alpha) of the color, where 0 means fully transparent and 1 fully opaque. By default, all colors are fully opaque.
- Returns:
a color with the provided RGBA components
Names of notable colors because they are at the vertices of the RGB cube, plus the fully-transparent one.
- black
Black color
- blue
Blue color
- cyan
Cyan color
- green
Green color
- magenta
Magenta color
- red
Red color
- transparent
Fully-transparent color
- white
White color
- yellow
Yellow color