cmap.Color#
cmap.Color(value: ColorLike) #
Class to represent a single color.
Instances of this class are immutable and cached (based on the rgba tuple), you can compare them with is.
Parameters:
-
value(str, tuple, list, array, Color, or int) –The color to represent. Can be any "ColorLike".
alpha: float property #
Return the alpha value.
hex: str property #
Return the color as hex.
hsl: HSLA property #
Return the color as Hue, Saturation, Lightness.
hsv: HSVA property #
Return the color as Hue, Saturation, Value.
name: str | None property #
Return the color as name.
rgba: RGBA property #
Return the color as (Red, Green, Blue, Alpha) tuple in 0-1 range.
rgba8: RGBA8 property #
Return the color as (Red, Green, Blue, Alpha) tuple in 0-255 range.
rgba_string: str property #
Return the color as an 'rgba(r, g, b, a)' string; 0-255 range.
__repr__() -> str #
Return a string representation of the color.
__rich_repr__() -> Any #
Provide a rich representation of the color, with color swatch.
__str__() -> str #
Return a string representation of the color.
from_int(value: int, format: str, bits_per_component: int | Sequence[int] = 8) -> Color classmethod #
Parse color from bit-shifted integer encoding.
Parameters:
-
value(int) –The integer value to parse.
-
format(str) –The format of the integer value. Must be a string composed only of the characters 'r', 'g', 'b', and 'a'.
-
bits_per_component(int | Sequence[int] | None, default:8) –The number of bits used to represent each color component. If a single integer is provided, it is used for all components. If a sequence of integers is provided, the length must match the length of
format.
to_int(format: str, bits_per_component: int | Sequence[int] = 8) -> int #
Convert color to bit-shifted integer encoding.
Parameters:
-
format(str) –The format of the integer value. Must be a string composed only of the characters 'r', 'g', 'b', and 'a'.
-
bits_per_component(int | Sequence[int] | None, default:8) –The number of bits used to represent each color component. If a single integer is provided, it is used for all components. If a sequence of integers is provided, the length must match the length of
format.