10.15. rgba

class itom.rgba(r, g, b, alpha=255)

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
rint

red component [0,255].

gint

green component [0,255].

bint

blue component [0,255].

alphaint, 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
float

The 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].