nanome.util.color module

class Color(r=0, g=0, b=0, a=255, whole_num=None)[source]

Bases: object

Represents a 32-bit color with red, green, blue and alpha channels (8 bits each).
Parameters:
  • r (int) – Red component
  • g (int) – Green component
  • b (int) – Blue component
  • a (int) – Alpha component
  • whole_num (int or hex) – Optional way to input color. The int or hex form of the color. e.g. 0x8000FFFF
classmethod Black()[source]
classmethod Blue()[source]
classmethod Clear()[source]
classmethod Gray()[source]
classmethod Green()[source]
classmethod Grey()[source]
classmethod Red()[source]
classmethod White()[source]
classmethod Yellow()[source]
a
The alpha component of the color.
Type:int
b
The blue component of the color.
Type:int
copy()[source]
Create a new color from this one.
Return type:Color
classmethod from_hex(value)[source]
Set color from hex after initializing.
Parameters:value (str) – Hex value of the color e.g. #ffffffff
classmethod from_int(value)[source]
Set color from int after initializing.
Parameters:value (int) – Int value of the color
g
The green component of the color.
Type:int
hex
Hex string representing the RGBA color.
e.g. #ffffffff
Return type:class:str
r
The red component of the color.
Type:int
rgb
rgba
set_color_int(num)[source]
Assigns the color an integer value representing
the red component bitshifted 24 bits, bitwise ORed with
the green component bitshifted 16 bits, bitwise ORed with
the blue component bitshifted 8 bits, ORed with
the alpha component, or more simply:
r << 24 | g << 16 | b << 8 | a
OR
0xRRGGBBAA
Parameters:num (int) – Number to set the color to
set_color_rgb(r=0, g=0, b=0, a=255)[source]
Assign a value by individual color components.
Parameters:
  • r (int (0-255)) – Red component
  • g (int (0-255)) – Green component
  • b (int (0-255)) – Blue component
  • a (int (0-255)) – Alpha component