treevalue.utils.color

Color

class treevalue.utils.color.Color(c: Union[str, Tuple[float, float, float]], alpha: Optional[float] = None)[source]
Overview:

Color utility object.

__eq__(other)[source]
Overview:

Get equality between colors.

Arguments:
  • other: Another object.

Returns:
  • equal (bool): Equal or not.

__getstate__() → Tuple[float, float, float, Optional[float]][source]
Overview:

Dump color as pickle object.

Returns:
  • info (Tuple[float, float, float, Optional[float]]): Dumped data object.

__hash__()[source]
Overview:

Get hash value of current object.

Returns:
  • hash (int): Hash value of current color.

__init__(c: Union[str, Tuple[float, float, float]], alpha: Optional[float] = None)[source]
Overview:

Constructor of Color.

Arguments:
  • c (Union[str, Tuple[float, float, float]]): Color value, can be hex string value or tuple rgb value.

  • alpha: (Optional[float]): Alpha value of color, default is None which means no alpha value.

__repr__()[source]

Return repr(self).

__setstate__(v: Tuple[float, float, float, Optional[float]])[source]
Overview:

Load color from pickle object.

Args:
  • v (Tuple[float, float, float, Optional[float]]): Dumped data object.

__str__()[source]

Return str(self).

property alpha
Overview:

Get value of alpha.

Returns:
  • alpha (Optional[float]): Alpha value.

classmethod from_hls(h: float, l: float, s: float, alpha: Optional[float] = None)treevalue.utils.color.Color[source]
Overview:

Load color from hls system.

Arguments:
  • h (float): Hue value, should be a float value in \(\left[0, 1\right)\).

  • l (float): Lightness value, should be a float value in \(\left[0, 1\right]\).

  • s (float): Saturation value, should be a float value in \(\left[0, 1\right]\).

  • alpha (Optional[float]): Alpha value, should be a float value in \(\left[0, 1\right]\), default is None which means no alpha value is used.

Returns:
  • color (Color): Color object.

classmethod from_hsv(h, s, v, alpha=None)treevalue.utils.color.Color[source]
Overview:

Load color from hsv system.

Arguments:
  • h (float): Hue value, should be a float value in \(\left[0, 1\right)\).

  • s (float): Saturation value, should be a float value in \(\left[0, 1\right]\).

  • v (float): Brightness (value) value, should be a float value in \(\left[0, 1\right]\).

  • alpha (Optional[float]): Alpha value, should be a float value in \(\left[0, 1\right]\), default is None which means no alpha value is used.

Returns:
  • color (Color): Color object.

property hls
Overview:

Get hls color system based color proxy.

Returns:
  • proxy (HLSColorProxy): Hls color proxy.

property hsv
Overview:

Get hsv color system based color proxy.

Returns:
  • proxy (HSVColorProxy): Hsv color proxy.

property rgb
Overview:

Get rgb color system based color proxy.

Returns:
  • proxy (RGBColorProxy): Rgb color proxy.