otx.api.entities.color#

This module define the color entity.

Classes

Color(red, green, blue[, alpha])

Represents an RGBA color.

ColorEntity(red, green, blue, alpha)

This class represents an abstract Color, some functions are still abstract.

class otx.api.entities.color.Color(red: int, green: int, blue: int, alpha: int = 255)[source]#

Bases: ColorEntity

Represents an RGBA color.

classmethod from_hex_str(string: str) Color[source]#

Creates Color() instance given a hex string.

Supports 6 character hex string (RGB), or 8 character hex string (RGBA). The string might optionally start with a number sign (#).

Example

Creating color object:

>>> Color.from_hex_str("#ff0000")
Color(red=255, green=0, blue=0, alpha=255)
>>> Color.from_hex_str("0000ff")
Color(red=0, green=0, blue=255, alpha=255)
>>> Color.from_hex_str("#96Ff00C8")
Color(red=150, green=255, blue=0, alpha=200)
Parameters:

string (str) – Hex string

Returns:

Color instance

classmethod random() Color[source]#

Generate random Color() instance.

Returns:

Color instance with random color

property bgr_tuple: Tuple[int, int, int]#

Retrieves the Color as a BGR tuple.

Returns:

Tuple[int, int, int]

property hex_str: str#

Returns the color in a Hex representation.

property rgb_tuple: Tuple[int, int, int]#

Retrieves the Color as a RGB tuple.

Returns:

Tuple[int, int, int]

class otx.api.entities.color.ColorEntity(red: int, green: int, blue: int, alpha: int)[source]#

Bases: object

This class represents an abstract Color, some functions are still abstract.

abstract classmethod from_hex_str(string: str)[source]#

Converts a hex string to a color.

Parameters:

string (str) – The hex string

abstract classmethod random()[source]#

Generates a random Color.

property alpha: int#

Returns the alpha value for the ColorEntity object.

property blue: int#

Returns the blue color value for the ColorEntity object.

property green: int#

Returns the green color value for the ColorEntity object.

abstract property hex_str: str#

Returns the color in a Hex representation.

property red: int#

Returns the red color value for the ColorEntity object.