colors#
- final class wyvern.colors.Color(value: int)[source]#
Class representing a color in the RGB color space. Alias name Colour exists for convenience.
- value#
The value of the color. This is a 24-bit integer, where the first 8 bits are the red value, the next 8 bits are the green value, and the last 8 bits are the blue value.
- Type:
- classmethod aqua() Color [source]#
Creates a Color object from the aqua color. This is
#00ffff
. (Aqua)
- classmethod black() Color [source]#
Creates a Color object from the black color. This is
0x000000
. (Black)
- classmethod blue() Color [source]#
Creates a Color object from the blue color. This is
0x0000ff
. (Blue)
- classmethod brown() Color [source]#
Creates a Color object from the brown color. This is
#a52a2a
. (Brown)
- classmethod cyan() Color [source]#
Creates a Color object from the cyan color. This is
0x00ffff
. (Cyan)
- classmethod default() Color [source]#
Creates a Color object from the default color. This is
0x000000
. (Black)Examples
>>> Color.default() Color(0)
- classmethod from_hex(hex_value: str) Color [source]#
Creates a Color object from a hex value.
Examples
>>> Color.from_hex('#ff0000') Color(16776960) >>> Color.from_hex('#00ff00') Color(255) >>> Color.from_hex('#0000ff') Color(0)
- classmethod from_hsl(h: float, s: float, l: float) Color [source]#
Creates a Color object from HSL values.
- Parameters:
- Returns:
A Color object.
- Return type:
Examples
>>> Color.from_hsl(0, 1, 0.5) Color(16711680) >>> Color.from_hsl(120, 1, 0.5) Color(16711680) >>> Color.from_hsl(240, 1, 0.5) Color(16711680)
- classmethod from_hsv(h: float, s: float, v: float) Color [source]#
Creates a Color object from HSV values.
- Parameters:
- Returns:
A Color object.
- Return type:
Examples
>>> Color.from_hsv(0, 1, 1) Color(16711680) >>> Color.from_hsv(120, 1, 1) Color(16711680) >>> Color.from_hsv(240, 1, 1) Color(16711680)
- classmethod from_random() Color [source]#
Creates a Color object from a random color. Randomly generates a color in the RGB color space.
- Returns:
A Color object.
- Return type:
- classmethod from_rgb(r: int, g: int, b: int) Color [source]#
Creates a Color object from RGB values.
- Parameters:
- Returns:
A Color object.
- Return type:
Examples
>>> Color.from_rgb(255, 0, 0) Color(16711680) >>> Color.from_rgb(0, 255, 0) Color(65280) >>> Color.from_rgb(0, 0, 255) Color(255)
- classmethod from_string(string: str) Color [source]#
Creates a Color object from a string.
Examples
>>> Color.from_string('rgb(255, 0, 0)') Color(16711680) >>> Color.from_string('hsl(0, 100%, 50%)') Color(-80727249750) >>> Color.from_string('hsv(0, 100%, 100%)') Color(1022371500) >>> Color.from_string('#ff0000') Color(16776960)
- classmethod gray() Color [source]#
Creates a Color object from the gray color. This is
0x808080
. (Gray)
- classmethod green() Color [source]#
Creates a Color object from the green color. This is
0x00ff00
. (Green)
- classmethod grey() Color [source]#
Creates a Color object from the grey color. This is
0x808080
. (Grey)
- classmethod magenta() Color [source]#
Creates a Color object from the magenta color. This is
0xff00ff
. (Magenta)
- classmethod orange() Color [source]#
Creates a Color object from the orange color. This is
0xffa500
. (Orange)
- classmethod purple() Color [source]#
Creates a Color object from the purple color. This is
#800080
. (Purple)
- classmethod red() Color [source]#
Creates a Color object from the red color. This is
0xff0000
. (Red)
- classmethod silver() Color [source]#
Creates a Color object from the silver color. This is
#c0c0c0
. (Silver)