Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ogdf::Color Class Reference

Colors represented as RGBA values. More...

#include <ogdf/basic/graphics.h>

Public Types

enum class  Name {
  Aliceblue , Antiquewhite , Aqua , Aquamarine , Azure , Beige , Bisque , Black , Blanchedalmond , Blue , Blueviolet , Brown , Burlywood , Cadetblue ,
  Chartreuse , Chocolate , Coral , Cornflowerblue , Cornsilk , Crimson , Cyan , Darkblue , Darkcyan , Darkgoldenrod , Darkgray , Darkgreen , Darkgrey , Darkkhaki ,
  Darkmagenta , Darkolivegreen , Darkorange , Darkorchid , Darkred , Darksalmon , Darkseagreen , Darkslateblue , Darkslategray , Darkslategrey , Darkturquoise , Darkviolet , Deeppink , Deepskyblue ,
  Dimgray , Dimgrey , Dodgerblue , Firebrick , Floralwhite , Forestgreen , Fuchsia , Gainsboro , Ghostwhite , Gold , Goldenrod , Gray , Green , Greenyellow ,
  Grey , Honeydew , Hotpink , Indianred , Indigo , Ivory , Khaki , Lavender , Lavenderblush , Lawngreen , Lemonchiffon , Lightblue , Lightcoral , Lightcyan ,
  Lightgoldenrodyellow , Lightgray , Lightgreen , Lightgrey , Lightpink , Lightsalmon , Lightseagreen , Lightskyblue , Lightslategray , Lightslategrey , Lightsteelblue , Lightyellow , Lime , Limegreen ,
  Linen , Magenta , 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 , Slategray , Slategrey , Snow , Springgreen , Steelblue , Tan , Teal , Thistle , Tomato ,
  Turquoise , Violet , Wheat , White , Whitesmoke , Yellow , Yellowgreen
}
 Named colors (same as SVG color keywords). More...
 

Public Member Functions

 Color ()
 Creates an opaque black color.
 
 Color (Color::Name name)
 Creates a color from given color name name.
 
 Color (const char *str)
 Crates a color from string str.
 
 Color (const string &str)
 Crates a color from string str.
 
 Color (int r, int g, int b, int a=255)
 Creates a color from given RGBA-values.
 
 Color (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
 Creates a color from given RGBA-values.
 
uint8_t alpha () const
 Returns the alpha channel.
 
void alpha (uint8_t a)
 Sets the alpha channel to a.
 
uint8_t blue () const
 Returns the blue component.
 
void blue (uint8_t b)
 Sets the blue component to b.
 
bool fromString (const string &str)
 Sets this color to the color defined by str.
 
uint8_t green () const
 Returns the green component.
 
void green (uint8_t g)
 Sets the green component to g.
 
bool operator!= (const Color &c) const
 Returns true iff c and this color differ in any component.
 
bool operator== (const Color &c) const
 Returns true iff c and this color are equal in every component.
 
uint8_t red () const
 Returns the red component.
 
void red (uint8_t r)
 Sets the red component to r.
 
string toString () const
 Converts the color to a string and returns it.
 

Private Attributes

uint8_t m_alpha
 
uint8_t m_blue
 
uint8_t m_green
 
uint8_t m_red
 

Friends

std::ostream & operator<< (std::ostream &os, const Color &c)
 Writes the string representation of color c to output stream os.
 

Detailed Description

Colors represented as RGBA values.

The Color class represents colors with four components: R (red), G (green), B (blue), and A (alpha channel). Each component has a value between and 255. The alpha channel controls tranparency, where an opaque color has an alpha channel of 255.

Definition at line 160 of file graphics.h.

Member Enumeration Documentation

◆ Name

Named colors (same as SVG color keywords).

Enumerator
Aliceblue 
Antiquewhite 
Aqua 
Aquamarine 
Azure 
Beige 
Bisque 
Black 
Blanchedalmond 
Blue 
Blueviolet 
Brown 
Burlywood 
Cadetblue 
Chartreuse 
Chocolate 
Coral 
Cornflowerblue 
Cornsilk 
Crimson 
Cyan 
Darkblue 
Darkcyan 
Darkgoldenrod 
Darkgray 
Darkgreen 
Darkgrey 
Darkkhaki 
Darkmagenta 
Darkolivegreen 
Darkorange 
Darkorchid 
Darkred 
Darksalmon 
Darkseagreen 
Darkslateblue 
Darkslategray 
Darkslategrey 
Darkturquoise 
Darkviolet 
Deeppink 
Deepskyblue 
Dimgray 
Dimgrey 
Dodgerblue 
Firebrick 
Floralwhite 
Forestgreen 
Fuchsia 
Gainsboro 
Ghostwhite 
Gold 
Goldenrod 
Gray 
Green 
Greenyellow 
Grey 
Honeydew 
Hotpink 
Indianred 
Indigo 
Ivory 
Khaki 
Lavender 
Lavenderblush 
Lawngreen 
Lemonchiffon 
Lightblue 
Lightcoral 
Lightcyan 
Lightgoldenrodyellow 
Lightgray 
Lightgreen 
Lightgrey 
Lightpink 
Lightsalmon 
Lightseagreen 
Lightskyblue 
Lightslategray 
Lightslategrey 
Lightsteelblue 
Lightyellow 
Lime 
Limegreen 
Linen 
Magenta 
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 
Slategray 
Slategrey 
Snow 
Springgreen 
Steelblue 
Tan 
Teal 
Thistle 
Tomato 
Turquoise 
Violet 
Wheat 
White 
Whitesmoke 
Yellow 
Yellowgreen 

Definition at line 165 of file graphics.h.

Constructor & Destructor Documentation

◆ Color() [1/6]

ogdf::Color::Color ( )
inline

Creates an opaque black color.

Definition at line 316 of file graphics.h.

◆ Color() [2/6]

ogdf::Color::Color ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
inline

Creates a color from given RGBA-values.

Definition at line 319 of file graphics.h.

◆ Color() [3/6]

ogdf::Color::Color ( int  r,
int  g,
int  b,
int  a = 255 
)
inline

Creates a color from given RGBA-values.

Definition at line 323 of file graphics.h.

◆ Color() [4/6]

ogdf::Color::Color ( Color::Name  name)

Creates a color from given color name name.

◆ Color() [5/6]

ogdf::Color::Color ( const string &  str)
inline

Crates a color from string str.

Definition at line 330 of file graphics.h.

◆ Color() [6/6]

ogdf::Color::Color ( const char str)
inline

Crates a color from string str.

Definition at line 333 of file graphics.h.

Member Function Documentation

◆ alpha() [1/2]

uint8_t ogdf::Color::alpha ( ) const
inline

Returns the alpha channel.

Definition at line 345 of file graphics.h.

◆ alpha() [2/2]

void ogdf::Color::alpha ( uint8_t  a)
inline

Sets the alpha channel to a.

Definition at line 357 of file graphics.h.

◆ blue() [1/2]

uint8_t ogdf::Color::blue ( ) const
inline

Returns the blue component.

Definition at line 342 of file graphics.h.

◆ blue() [2/2]

void ogdf::Color::blue ( uint8_t  b)
inline

Sets the blue component to b.

Definition at line 354 of file graphics.h.

◆ fromString()

bool ogdf::Color::fromString ( const string &  str)

Sets this color to the color defined by str.

Parameters
strstring of the form "#rgb" or "#rrggbb"
Returns
true iff the conversion succeeded (i.e., the string was a valid color string of the form "#rgb" or "#rrggbb"). If the conversion did not succeed, false is returned, and this Color is set to black.

◆ green() [1/2]

uint8_t ogdf::Color::green ( ) const
inline

Returns the green component.

Definition at line 339 of file graphics.h.

◆ green() [2/2]

void ogdf::Color::green ( uint8_t  g)
inline

Sets the green component to g.

Definition at line 351 of file graphics.h.

◆ operator!=()

bool ogdf::Color::operator!= ( const Color c) const
inline

Returns true iff c and this color differ in any component.

Definition at line 382 of file graphics.h.

◆ operator==()

bool ogdf::Color::operator== ( const Color c) const
inline

Returns true iff c and this color are equal in every component.

Definition at line 377 of file graphics.h.

◆ red() [1/2]

uint8_t ogdf::Color::red ( ) const
inline

Returns the red component.

Definition at line 336 of file graphics.h.

◆ red() [2/2]

void ogdf::Color::red ( uint8_t  r)
inline

Sets the red component to r.

Definition at line 348 of file graphics.h.

◆ toString()

string ogdf::Color::toString ( ) const

Converts the color to a string and returns it.

Colors as represented as strings using the #RRGGBB hex notation. Please note that in this notation the alpha channel is not represented and is assumed to be 255 (an opaque color).

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Color c 
)
friend

Writes the string representation of color c to output stream os.

Definition at line 385 of file graphics.h.

Member Data Documentation

◆ m_alpha

uint8_t ogdf::Color::m_alpha
private

Definition at line 161 of file graphics.h.

◆ m_blue

uint8_t ogdf::Color::m_blue
private

Definition at line 161 of file graphics.h.

◆ m_green

uint8_t ogdf::Color::m_green
private

Definition at line 161 of file graphics.h.

◆ m_red

uint8_t ogdf::Color::m_red
private

Definition at line 161 of file graphics.h.


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