Skip to content

RGB

ColorRGB

ColorRGB(r: int, g: int, b: int)

Red, Green, Blue - Color Object.

Create a new RGB color.

PARAMETER DESCRIPTION
r

The red color value (0-255).

TYPE: int

g

The green color value (0-255).

TYPE: int

b

The blue color value (0-255).

TYPE: int

RAISES DESCRIPTION
TypeError

If r, g, or b are not int.

ValueError

If r, g, or b are not between 0 and 255.

b property writable

b: int

The blue color value.

g property writable

g: int

The green color value.

nb property writable

nb: float

The normalized blue color value.

ng property writable

ng: float

The normalized green color value.

nr property writable

nr: float

The normalized red color value.

r property writable

r: int

The red color value.

copy

copy() -> ColorRGB

Create a copy of this color.

RETURNS DESCRIPTION
ColorRGB

An exact replica of this color.

from_iterable classmethod

from_iterable(
    iterable: Union[
        ColorRGB,
        tuple[int, int, int],
        list[int],
        NDArray[numpy.uint8],
    ],
) -> ColorRGB

Create a new RGB color from an iterable object.

PARAMETER DESCRIPTION
iterable

The iterable object to create the color from.

TYPE: (ColorRGB | tuple[int, int, int], list[int], NDArray[numpy.uint8])

RAISES DESCRIPTION
TypeError

If RGB values are not int.

ValueError
  • If provided iterable is not 3 objects in length.
  • If RGB values are not between 0 and 255.

hex

hex() -> str

Return the hexadecimal representation of this color.

hsl

hsl() -> tuple[float, float, float]

Return the HSL representation of this color.

hsv

hsv() -> tuple[float, float, float]

Return the HSV representation of this color.

int

int() -> int

Return the packed integer representation of this color.

normalized

normalized() -> tuple[float, float, float]

Return the normalized color values.

RETURNS DESCRIPTION
tuple[float, float, float]

The normalized color values.

to_numpy

to_numpy() -> NDArray[numpy.uint8]

Return this color as a NumPy array.

RETURNS DESCRIPTION
NDArray[numpy.uint8]

This color as an array.

to_tuple

to_tuple() -> tuple[int, int, int]

Return this color as a tuple.

RETURNS DESCRIPTION
tuple[int, int, int]

This color as a tuple.

ColorRGBA

ColorRGBA(r: int, g: int, b: int, a: float)

Bases: ColorRGB

Red, Green, Blue, Alpha - Color Object.

Create a new RGBA color.

PARAMETER DESCRIPTION
r

The red color value (0-255).

TYPE: int

g

The green color value (0-255).

TYPE: int

b

The blue color value (0-255).

TYPE: int

a

The alpha/transparency value (0-1).

TYPE: float

RAISES DESCRIPTION
TypeError
  • If r, g, or b are not int.
  • If a is not float or int.
ValueError
  • If r, g, or b are not between 0 and 255.
  • If a is not between 0 and 1.

a property writable

a: float

The alpha/transparency value.

b property writable

b: int

The blue color value.

g property writable

g: int

The green color value.

nb property writable

nb: float

The normalized blue color value.

ng property writable

ng: float

The normalized green color value.

nr property writable

nr: float

The normalized red color value.

r property writable

r: int

The red color value.

copy

copy() -> ColorRGBA

Create a copy of this color.

RETURNS DESCRIPTION
ColorRGBA

An exact replica of this color.

from_iterable classmethod

from_iterable(
    iterable: Union[
        ColorRGBA,
        tuple[int, int, int, float],
        list[int, float],
        NDArray[Union[numpy.uint8, numpy.float16]],
    ],
) -> ColorRGBA

Create a new RGBA color from an iterable object.

PARAMETER DESCRIPTION
iterable

The iterable object to create the color from.

TYPE: (ColorRGBA | tuple[int, int, int, float], list[int, float], NDArray[numpy.uint8 | numpy.float16])

RAISES DESCRIPTION
TypeError
  • If RGB values are not int.
  • If alpha value is not int or float.
ValueError
  • If provided iterable is not 3-4 objects in length.
  • If RGB values are not between 0 and 255.
  • If alpha value is not between 0 and 1.

hex

hex() -> str

Return the hexadecimal representation of this color.

hsla

hsla() -> tuple[float, float, float, float]

Return the HSLA representation of this color.

hsva

hsva() -> tuple[float, float, float, float]

Return the HSV representation of this color.

int

int() -> int

Return the packed integer representation of this color.

normalized

normalized() -> tuple[float, float, float, float]

Return the normalized color values.

RETURNS DESCRIPTION
tuple[float, float, float, float]

The normalized color values.

to_numpy

to_numpy() -> NDArray[numpy.float16]

Return this color as a NumPy array.

RETURNS DESCRIPTION
NDArray[numpy.float16]

This color as an array.

to_tuple

to_tuple() -> tuple[int, int, int, float]

Return this color as a tuple.

RETURNS DESCRIPTION
tuple[int, int, int, float]

This color as a tuple.

hsl

hsl() -> tuple[float, float, float]

Return the HSL representation of this color.

hsv

hsv() -> tuple[float, float, float]

Return the HSV representation of this color.