ColorHex

class ColorHex(*args)

Bases: Color

Create a Hexadecimal color by passing a hexstring with an optional alpha parameter. The ‘#’ is optional.

Convert another color object to Hexadecimal by passing it as a parameter.

Raises

TypeError – hexstring must be a string, alpha must be a float

Examples

>>> ColorHex("#000")
"#000000"
>>> ColorHex("a7b7c7")
"#a7b7c7"
>>> ColorHex(other_color)
__repr__() str
Returns

str – the hexadecimal string

property red: int
property green: int
property blue: int
property alpha: float
__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