Color

class Color(*args)

Bases: object

Create colors by passing RGB arguments or a hexstring. Specify an alpha value by passing a float as the last parameter.

Raises

ValueError – unrecognised or invalid parameters

Examples

>>> Color(120, 70, 0)
Color(120, 70, 0)
>>> Color("#fff")
Color(255, 255, 255)
>>> Color(60, 180, 90, 0.5)
Color(60, 180, 90)
__add__(other: Union[int, Color]) Color

Adds an integer value to the RGB components of the color, or adds the RGB components of another color supplied. You can also use in-place addition.

Examples

>>> Color(120, 50, 60) + 5  # increases the brightness by 5 points
Color(125, 55, 65)
>>> Color(15, 20, 30) + Color(60, 5, 30)
Color(75, 25, 60)
Return type

Color

__sub__(other: Union[int, Color]) Color

Subtracts an integer value from the RGB components of the color, or subtracts the RGB components of another color supplied. You can also use in-place subtraction.

Examples

>>> Color(120, 50, 60) - 5  # decreases the brightness by 5 points
Color(115, 45, 55)
>>> Color(60, 80, 100) - Color(10, 20, 30)
Color(50, 60, 70)
Return type

Color

property red: int
property green: int
property blue: int
property alpha: float