ColorRGB

class ColorRGB(*args)

Bases: Color

Create an RGB color by passing RGB arguments with an optional alpha parameter.

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

Raises
  • TypeError – expected integers for RGB and floats for alpha

  • ValueError – RGB must be between 0-255, alpha must be between 0-1

Examples

>>> ColorRGB(120, 70, 0)
ColorRGB(120, 70, 0)
>>> ColorRGB(60, 180, 90, 0.5)
Color(60, 180, 90)
>>> ColorRGB(other_color)
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