Bridges-Python-3.0.0  3.0.0b
Bridges(PythonAPI)
Public Member Functions | Public Attributes | List of all members
bridges.color.Color Class Reference
Inheritance diagram for bridges.color.Color:

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

    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
>>> my_color = Color("red") >>> my_color.rgba (255, 0, 0, 1.0) >>> my_color = Color(r=255) >>> my_color.rgba (255, 0, 0, 1.0) >>> my_color = Color(255, 0, 0) >>> my_color.rgba (255, 0, 0, 1.0) >>> my_color = Color() >>> my_color.red = 255 >>> my_color.rgba (255, 0, 0, 1.0)

Public Member Functions

def red (self)
 
def red
 Setter for red component of color (0-255 inclusive) More...
 
def green (self)
 Getter for green component of color (0-255 inclusive) More...
 
def green
 Setter for green component of color (0-255 inclusive) More...
 
def blue (self)
 Getter for blue component of color (0-255 inclusive) More...
 
def blue
 Setter for blue component of color (0-255 inclusive) More...
 
def alpha (self)
 Getter for alpha(opacity) component of color (0-1.0 inclusive) More...
 
def alpha
 Setter for alpha component of color (0-1.0 inclusive) More...
 
def rgba (self, int, int, int, float)
 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 :return (int, int, int, float): RGBA values respectively. More...
 
def rgba
 
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 :param args: int, int, int, optional float or just a str :param kwargs: r/red: int, b/blue: int, g/green: int optional a/alpha: float or col_name: str :return: None. More...
 
def set_color (self, args, kwargs)
 
def get_byte_representation (self)
 :return list(int):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
 alpha component of color ranging from 0.0-1.0 inclusive (default 1.0) More...
 
 red
 red component of color ranging from 0-255 inclusive (default 0) More...
 
 green
 green component of color ranging from 0-255 inclusive (default 0) More...
 
 blue
 blue component of color ranging from 0-255 inclusive (default 0) More...
 

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 :param args: int, int, int, optional float or just a str :param kwargs: r/red: int, b/blue: int, g/green: int optional a/alpha: float or col_name: str :return: None.

Member Function Documentation

◆ __eq__()

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

deep equality check, by value of each RGBA value

◆ alpha() [1/2]

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

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,
  value 
)

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

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

◆ blue() [1/2]

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

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

Returns
int blue component of color

◆ blue() [2/2]

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

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

Parameters
valueblue component of color
Returns
None

◆ get_byte_representation()

def bridges.color.Color.get_byte_representation (   self,
  list 
)

:return list(int):RGBA values as list of ints from 0-255

◆ green() [1/2]

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

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

Returns
int green component of color

◆ green() [2/2]

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

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

Parameters
valuegreen component of color
Returns
None

◆ red() [1/2]

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

◆ red() [2/2]

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

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

Parameters
valuered component of color
Returns
None

◆ rgba() [1/2]

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

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 :return (int, int, int, float): RGBA values respectively.

◆ rgba() [2/2]

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

◆ set_color()

def bridges.color.Color.set_color (   self,
  args,
  kwargs,
  None 
)

Member Data Documentation

◆ alpha

bridges.color.Color.alpha

alpha component of color ranging from 0.0-1.0 inclusive (default 1.0)

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

Returns
int red component of color

◆ blue

bridges.color.Color.blue

blue component of color ranging from 0-255 inclusive (default 0)

◆ green

bridges.color.Color.green

green component of color ranging from 0-255 inclusive (default 0)

◆ red

bridges.color.Color.red

red component of color ranging from 0-255 inclusive (default 0)


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