Color value object (RGB + optional alpha channel).
Creates a new color value from red, green, blue and optional alpha.
If any value > 255 is passed as argument, its modulo with 256 is taken instead.
The rgba object implements many methods of the number protocol,
such that it becomes possible to add, subtract, multiply… two colors. In most
cases these operations are executed for each color component independently.
- Parameters:
- r
int red component [0,255].
- g
int green component [0,255].
- b
int blue component [0,255].
- alpha
int, optional alpha component [0,255], default: 255 (opaque).
Notes
For a gray value set all colors to the same value.
-
name() → str
Returns the name of this object (rgba).
-
toGray() → float
returns the gray value from the color (alpha is not considered)
- Returns:
floatThe returned gray value is a float value and calculated by
0.299 * r + 0.587 * g + 0.114 * b
-
alpha
int : alpha (transparency) component of this color [0, 255].
-
b
int : blue component of this color [0, 255].
-
g
int : red component of this color [0, 255].
-
r
int : red component of this color [0, 255].