![]() |
Bridges-Python
3.4.5-dev2-5-g352f189
Bridges(Python API)
|
This class is used to represent colors in bridges. More...
Public Member Functions | |
int | red (self) |
def | red (self, int value) |
Setter for red component of color (0-255 inclusive) More... | |
int | green (self) |
def | green (self, int value) |
Setter for green component of color (0-255 inclusive) More... | |
int | blue (self) |
def | blue (self, int value) |
float | alpha (self) |
def | alpha (self, float value) |
(int, int, int, float) | rgba (self) |
RGBA components as respective tuple. More... | |
def | rgba (self,(int, int, int, float) rgba) |
Set RGBA components. More... | |
def | __init__ (self, *args, **kwargs) |
Constructor for a Color object Usage requires either 3 ints 0-255 for RGB and an optional float 0.0-1.0 for alpha or a str of a web color can also key the RGBA values with r, g, b, a or red, green, blue, alpha respectively and col_name for the str. More... | |
None | set_color (self, *args, **kwargs) |
Sets color for a an element or link. More... | |
list | get_byte_representation (self) |
Gets the RGBA values as list of ints from 0-255. More... | |
None | write_byte_representation (self, list[int] bytebuffer) |
def | __eq__ (self, other) |
deep equality check, by value of each RGBA value More... | |
Public Attributes | |
alpha | |
red | |
green | |
blue | |
This class is used to represent colors in bridges.
We use and RGBA model to represent colors, with the Red, Green, and Blue components ranging from 0-255, with the alpha ranging from 0.0-1.0 inclusive.
We use webcolors to handle color names passed to the constructor/set_color function. https://www.w3.org/TR/css-color-3/#svg-color
Color names are listed below:
def bridges.color.Color.__init__ | ( | self, | |
* | args, | ||
** | kwargs | ||
) |
Constructor for a Color object Usage requires either 3 ints 0-255 for RGB and an optional float 0.0-1.0 for alpha or a str of a web color can also key the RGBA values with r, g, b, a or red, green, blue, alpha respectively and col_name for the str.
args0 | colname |
args0 | (r,g,b,a) |
args0 | r |
args1 | g |
args2 | b |
args3 | alpha |
blue | Optional(int) |
green | Optional(int) |
alpha | Optional(float) |
red | Optional(int) |
r | Optional(int) |
b | Optional(int) |
g | Optional(int) |
a | Optional(float) |
col_name | Optional(str) |
ValueError | if args is not 3 ints with an optional 4th arg for alpha or just one str arg |
ValueError | if a str passed is not a valid webcolor |
ValueError | if any of the RGBA values are outside of their respective range |
Examples
def bridges.color.Color.__eq__ | ( | self, | |
other | |||
) |
deep equality check, by value of each RGBA value
float bridges.color.Color.alpha | ( | self | ) |
def bridges.color.Color.alpha | ( | self, | |
float | value | ||
) |
int bridges.color.Color.blue | ( | self | ) |
def bridges.color.Color.blue | ( | self, | |
int | value | ||
) |
list bridges.color.Color.get_byte_representation | ( | self | ) |
Gets the RGBA values as list of ints from 0-255.
int bridges.color.Color.green | ( | self | ) |
def bridges.color.Color.green | ( | self, | |
int | value | ||
) |
Setter for green component of color (0-255 inclusive)
value | green component of color |
int bridges.color.Color.red | ( | self | ) |
def bridges.color.Color.red | ( | self, | |
int | value | ||
) |
Setter for red component of color (0-255 inclusive)
value | red component of color |
(int, int, int, float) bridges.color.Color.rgba | ( | self | ) |
RGBA components as respective tuple.
Represents the RGBA values of the color as a tuple, can be used to set or get all values at once
def bridges.color.Color.rgba | ( | self, | |
(int, int, int, float) | rgba | ||
) |
Set RGBA components.
rgba | r,g,b,a (list) |
None bridges.color.Color.set_color | ( | self, | |
* | args, | ||
** | kwargs | ||
) |
Sets color for a an element or link.
Requires either 3 ints 0-255 for RGB and an optional float 0.0-1.0 for alpha or a str of a web color can also key the RGBA values with r, g, b, a or red, green, blue, alpha respectively and col_name for the str
args | int, int, int optional float or str |
kwargs | r/red: int, b/blue: int, g/green: int optional a/alpha: float or col_name: str |
None bridges.color.Color.write_byte_representation | ( | self, | |
list[int] | bytebuffer | ||
) |
bridges.color.Color.alpha |
bridges.color.Color.blue |
bridges.color.Color.green |
bridges.color.Color.red |