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

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

Attributes: red (int): red component of color ranging from 0-255 inclusive (default 0) green (int): green component of color ranging from 0-255 inclusive (default 0) blue (int): blue component of color ranging from 0-255 inclusive (default 0) alpha (float): alpha component of color ranging from 0.0-1.0 inclusive (default 1.0) rgba (tuple(int, int, int, alpha)): RGBA components as respective tuple

Parameters
argsint, int, int, Optional(float) or a str as singular arg
       r or red: Optional(int)
       b or blue: Optional(int)
       g or green: Optional(int)
       a or alpha: Optional(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)
\end{code}

Public Member Functions

int red (self)
 Getter for red component of color (0-255 inclusive) More...
 
def red (self, int value)
 Setter for red component of color (0-255 inclusive) More...
 
int green (self)
 Getter for green component of color (0-255 inclusive) More...
 
def green (self, int value)
 Setter for green component of color (0-255 inclusive) More...
 
int blue (self)
 Getter for blue component of color (0-255 inclusive) More...
 
def blue (self, int value)
 Setter for blue component of color (0-255 inclusive) More...
 
float alpha (self)
 Getter for alpha(opacity) component of color (0-1.0 inclusive) More...
 
def alpha (self, float value)
 Setter for alpha component of color (0-1.0 inclusive) More...
 
(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...
 
def __eq__ (self, other)
 deep equality check, by value of each RGBA value More...
 

Public Attributes

 alpha
 
 red
 
 green
 
 blue
 

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
argsint, int, int, optional float or just a str
kwargsr/red: int, b/blue: int, g/green: int optional a/alpha: float or col_name: str
Returns
None

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)

Getter for alpha(opacity) component of color (0-1.0 inclusive)

Returns
float alpha component of color

◆ alpha() [2/2]

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

Setter for alpha component of color (0-1.0 inclusive)

Parameters
valuealpha component of color (0-1.0)
Returns
None

◆ blue() [1/2]

int bridges.color.Color.blue (   self)

Getter for blue component of color (0-255 inclusive)

Returns
int blue component of color

◆ blue() [2/2]

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

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

Parameters
valueblue component of color
Returns
None

◆ 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)

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

Returns
int green component of color

◆ 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)

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

Returns
(int) red component of color

◆ 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

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: