RGBA#

class tqec.interop.RGBA(r, g, b, a)[source]#

Bases: object

RGBA representation of a color.

Parameters:
  • r (int)

  • g (int)

  • b (int)

  • a (float)

r#

Red component of the color, in the range [0, 255].

Type:

int

g#

Green component of the color, in the range [0, 255].

Type:

int

b#

Blue component of the color, in the range [0, 255].

Type:

int

a#

Alpha component of the color, in the range [0, 1].

Type:

float

Methods

__init__(r, g, b, a)

as_floats()

Returns the color as a tuple of floats.

to_hex()

Returns the color as a hexadecimal string.

with_alpha(a)

Returns a new RGBA with the same color but a different alpha value.

Attributes

r

g

b

a

Detailed methods

__init__(r, g, b, a)#
Parameters:
  • r (int)

  • g (int)

  • b (int)

  • a (float)

Return type:

None

as_floats()[source]#

Returns the color as a tuple of floats. The RGB values are normalized to the range [0, 1].

Returns:

Length 4 tuple of floats representing the color.

Return type:

tuple[float, float, float, float]

to_hex()[source]#

Returns the color as a hexadecimal string.

Returns:

The color as a hexadecimal string.

Return type:

str

with_alpha(a)[source]#

Returns a new RGBA with the same color but a different alpha value.

Parameters:

a (float) – The new alpha value.

Returns:

A new RGBA with the same color but a different alpha value.

Return type:

RGBA