colors module

Provides Color objects with RGBA values.

class colors.Color

Bases: Boost.Python.instance

This class is used to store a 32 bit color. The color is stored in its RGBA components.

__eq__((Color)arg1, (Color)arg2) → object
__getitem__((Color)arg1, (Channel)index) → int :

Return the color component at the given index (0 - 3).

Parameters:index (int) – An index between 0 and 3 that defines the color component to get.
Returns:The color component value.
Return type:int
__init__((object)arg1[, (int)r=0[, (int)g=0[, (int)b=0[, (int)a=255]]]]) → None :

Initialize the Color object.

Parameters:
__ne__((Color)arg1, (Color)arg2) → object
__reduce__()
__repr__((Color)arg1) → str :

Return the color as a stringified tuple.

__setitem__((Color)arg1, (Channel)index, (int)value) → None :

Set the color component at the given index.

Parameters:
  • index (int) – An index between 0 and 3 that defines the color component to set.
  • value (int) – A value between 0 and 255 that defines the new color component value.
__str__((Color)arg1) → str :

Return the color as a hexadecimal string.

with_alpha((Color)arg1, (int)a) → Color :

Return a copy of the color with a new alpha value.

Parameters:a (int) – The new alpha value.
a

A value between 0 and 255 that defines the alpha value (transparency).

b

A value between 0 and 255 that defines the blue component of the color.

g

A value between 0 and 255 that defines the green component of the color.

r

A value between 0 and 255 that defines the red component of the color.

colors.BLACK = Color(0, 0, 0, 255)
colors.BLUE = Color(0, 0, 255, 255)
colors.BROWN = Color(139, 69, 19, 255)
colors.CYAN = Color(0, 255, 255, 255)
colors.DARK_BLUE = Color(0, 0, 128, 255)
colors.DARK_GRAY = Color(64, 64, 64, 255)
colors.DARK_GREEN = Color(0, 128, 0, 255)
colors.DARK_RED = Color(128, 0, 0, 255)
colors.GRAY = Color(128, 128, 128, 255)
colors.GREEN = Color(0, 255, 0, 255)
colors.LIGHT_BLUE = Color(128, 128, 255, 255)
colors.LIGHT_GRAY = Color(192, 192, 192, 255)
colors.LIGHT_GREEN = Color(128, 255, 128, 255)
colors.LIGHT_RED = Color(255, 80, 80, 255)
colors.OLIVE = Color(128, 128, 0, 255)
colors.ORANGE = Color(255, 165, 0, 255)
colors.PURPLE = Color(255, 0, 255, 255)
colors.RED = Color(255, 0, 0, 255)
colors.WHITE = Color(255, 255, 255, 255)
colors.YELLOW = Color(255, 255, 0, 255)