Bridges-Python  3.4.5-dev2-5-g352f189
Bridges(Python API)
Public Member Functions | Public Attributes | List of all members
bridges.color.Color Class Reference

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
 

Detailed Description

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:

aliceblue, antiquewhite, cyan, aquamarine, azure, beige, bisque,
black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson,
darkblue, darkcyan, darkgoldenrod, darkgrey, darkgreen, darkkhaki,
darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
darksalmon, darkseagreen, darkslateblue, darkslategrey, darkturquoise,
darkviolet, deeppink, deepskyblue, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, magenta, gainsboro, ghostwhite, gold,
goldenrod, grey, green, greenyellow, honeydew, hotpink, indianred,
indigo, ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow,
lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategrey, lightsteelblue, lightyellow, lime,
limegreen, linen, maroon, mediumaquamarine, mediumblue, mediumorchid,
mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose,
moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange,
orangered, orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink, plum,
powderblue, purple, red, rosybrown, royalblue, saddlebrown,
salmon, sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategrey, snow, springgreen, steelblue, tan,
teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen

Constructor & Destructor Documentation

◆ __init__()

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.

Parameters
args0colname
args0(r,g,b,a)
args0r
args1g
args2b
args3alpha
blueOptional(int)
greenOptional(int)
alphaOptional(float)
redOptional(int)
rOptional(int)
bOptional(int)
gOptional(int)
aOptional(float)
col_nameOptional(str)
Exceptions
ValueErrorif args is not 3 ints with an optional 4th arg for alpha or just one str arg
ValueErrorif a str passed is not a valid webcolor
ValueErrorif any of the RGBA values are outside of their respective range

Examples

@code
my_color = Color("red") # equivalent to (255, 0, 0, 1.0)
my_color.rgba(255, 0, 0, 1.0) # using rgba notation
my_color = Color(r=255) # equivalent to (255, 0, 0, 1.0)
my_color = Color(255, 0, 0) # equivalent to (255, 0, 0, 1.0)
my_color = Color()
my_color.red = 255 # equivalent to (255, 0, 0, 1.0)

Member Function Documentation

◆ __eq__()

def bridges.color.Color.__eq__ (   self,
  other 
)

deep equality check, by value of each RGBA value

◆ alpha() [1/2]

float bridges.color.Color.alpha (   self)

◆ alpha() [2/2]

def bridges.color.Color.alpha (   self,
float  value 
)

◆ blue() [1/2]

int bridges.color.Color.blue (   self)

◆ blue() [2/2]

def bridges.color.Color.blue (   self,
int  value 
)

◆ get_byte_representation()

list bridges.color.Color.get_byte_representation (   self)

Gets the RGBA values as list of ints from 0-255.

Returns
byte representation of color

◆ green() [1/2]

int bridges.color.Color.green (   self)

◆ green() [2/2]

def bridges.color.Color.green (   self,
int  value 
)

Setter for green component of color (0-255 inclusive)

Parameters
valuegreen component of color
Returns
None

◆ red() [1/2]

int bridges.color.Color.red (   self)

◆ red() [2/2]

def bridges.color.Color.red (   self,
int  value 
)

Setter for red component of color (0-255 inclusive)

Parameters
valuered component of color
Returns
None

◆ rgba() [1/2]

(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

Returns
(int, int, int, float) - RGBA values respectively

◆ rgba() [2/2]

def bridges.color.Color.rgba (   self,
(int, int, int, float)  rgba 
)

Set RGBA components.

Parameters
rgbar,g,b,a (list)
Returns
None

◆ set_color()

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

Parameters
argsint, int, int optional float or str
kwargsr/red: int, b/blue: int, g/green: int optional a/alpha: float or col_name: str

◆ write_byte_representation()

None bridges.color.Color.write_byte_representation (   self,
list[int]  bytebuffer 
)

Member Data Documentation

◆ alpha

bridges.color.Color.alpha

◆ blue

bridges.color.Color.blue

◆ green

bridges.color.Color.green

◆ red

bridges.color.Color.red

The documentation for this class was generated from the following file: