Bridges-C++  3.4.2
Bridges(C++ API)
Public Member Functions | List of all members
bridges::datastructure::Color Class Reference

#include <Color.h>

Detailed Description

This class represents Color, and supports rgba, hexadecimal and named color values.

This class contains functions for the manipulation of a Color representation.

Supported rgba colors are integer representations of each color channel, in the range of [0,255]. rgb input is also supported, and given a default alpha value of 255 (opaque)

Supported Hexadecimal colors are in the form "#RRGGBBAA", "#RRGGBB", "#RGBA", or "#RGB". With R,G,B and A, representing the Red, Green, Blue, and Alpha color channels respectivly, in hexadecimal digits(0-9a-f, base 16) prefixed by '#'. "#RGBA" and "#RGB" are shorthand versions of "#RRGGBBAA" and "#RRGGBB", where each channel pair is the same. If no alpha channel is provided, a default of 'ff'(opaque) will be used

Supported named colors are as follows and illustrated at Supported named colors are listed here: https://drafts.csswg.org/css-color-3/#svg-color

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

All named colors have are fully opaque by default.

Default Color is opaque white

Date
7/8/19, Kalpathi Subramanian

Public Member Functions

 Color ()
 
 Color (const int r, const int g, const int b, const int a=255)
 
 Color (const string &name)
 
bool operator== (const Color &that) const
 
bool operator!= (const Color &that) const
 
bool isOpaque () const
 
bool isTransparent () const
 
int getRed () const
 
int getGreen () const
 
int getBlue () const
 
int getAlpha () const
 
string getHexValue () const
 
void setRed (int r)
 
void setGreen (int g)
 
void setBlue (int b)
 
void setAlpha (int a)
 
void setValue (int r, int g, int b, int a=255)
 
void setValue (string name)
 
const string getRepresentation () const
 
const string getCSSRepresentation () const
 

Constructor & Destructor Documentation

◆ Color() [1/3]

bridges::datastructure::Color::Color ( )
inline

Default constructor Defaults to black

◆ Color() [2/3]

bridges::datastructure::Color::Color ( const int  r,
const int  g,
const int  b,
const int  a = 255 
)
inline

Constructs a color with the specified rgba color channel values [0,255]. If no alpha channel is provided, the default of 255(opaque) is used.

Parameters
rThe red channel
gThe green channel
bThe blue channel
aThe alpha channel(default 255)

◆ Color() [3/3]

bridges::datastructure::Color::Color ( const string &  name)
inline

Constructs a color from a named color or a "#hexadecimal" [0-F](base 16) of the form "#RRGGBBAA", "#RRGGBBAA", "#RGBA", or "#RGB". Named colors and "#hexadecimals" missing an alpha channel are made opaque.

Parameters
nameThe named color or "#hexadecimal" value

Member Function Documentation

◆ getAlpha()

int bridges::datastructure::Color::getAlpha ( ) const
inline

Get alpha component

Returns
rgba value of the alpha channel [0,255]

◆ getBlue()

int bridges::datastructure::Color::getBlue ( ) const
inline

Get blue component

Returns
rgba value of the blue channel [0,255]

◆ getCSSRepresentation()

const string bridges::datastructure::Color::getCSSRepresentation ( ) const
inline

Gets the CSS representation of this color

Returns
a JSON vector of 4 dimensions that represents a CSS color in RGBA space, that is to say R, G, and B are between 0 and 255; and A is between 0 and 1

◆ getGreen()

int bridges::datastructure::Color::getGreen ( ) const
inline

Get green component

Returns
rgba value of the green channel [0,255]

◆ getHexValue()

string bridges::datastructure::Color::getHexValue ( ) const
inline
Returns
The "#hexadecimal" representation ("#RRGGBBAA") of this color

◆ getRed()

int bridges::datastructure::Color::getRed ( ) const
inline

Get red component

Returns
rgba value of the red channel [0,255]

◆ getRepresentation()

const string bridges::datastructure::Color::getRepresentation ( ) const
inline

◆ isOpaque()

bool bridges::datastructure::Color::isOpaque ( ) const
inline
Returns
True if fully opaque, false if not

◆ isTransparent()

bool bridges::datastructure::Color::isTransparent ( ) const
inline

Checks for transparency

Returns
True if fully transparent, false if not

◆ operator!=()

bool bridges::datastructure::Color::operator!= ( const Color that) const
inline

Inequality Comparison Operator

Returns
False if both Colors represent the same Color, true if not

◆ operator==()

bool bridges::datastructure::Color::operator== ( const Color that) const
inline

Equality Comparison Operator

Returns
True if both Colors represent the same Color, false if not

◆ setAlpha()

void bridges::datastructure::Color::setAlpha ( int  a)
inline

Sets alpha channel to "a"

Parameters
argba value to set alpha channel

◆ setBlue()

void bridges::datastructure::Color::setBlue ( int  b)
inline

Sets blue channel to "b"

Parameters
brgba value to set blue channel

◆ setGreen()

void bridges::datastructure::Color::setGreen ( int  g)
inline

Sets green channel to "g"

Parameters
grgba value to set green channel

◆ setRed()

void bridges::datastructure::Color::setRed ( int  r)
inline

Sets red channel to "r"

Parameters
rrgba value to set red channel

◆ setValue() [1/2]

void bridges::datastructure::Color::setValue ( int  r,
int  g,
int  b,
int  a = 255 
)
inline

Sets this color's value to the specified rgba color channel values [0,255]. If no alpha channel is provided, the default of 255(opaque) is used.

Parameters
rrgba value to set the red channel
grgba value to set the green channel
brgba value to set the blue channel
argba value to set the alpha channel

◆ setValue() [2/2]

void bridges::datastructure::Color::setValue ( string  name)
inline

Sets this color's value to the value of a named color or a "#hexadecimal" [0-F](base 16) of the form "#RRGGBBAA", "#RRGGBBAA", "#RGBA", or "#RGB". Named colors and "#hexadecimals" missing an alpha channel are made opaque.

Parameters
nameThe named color or "#hexadecimal" value
Exceptions
stringIf name is an invalid color

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