Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

ogdf::Color Class Reference

Colors represented as RGBA values. More...

#include <ogdf/basic/graphics.h>

Public Types

enum  Name {
  Name::Aliceblue, Name::Antiquewhite, Name::Aqua, Name::Aquamarine, Name::Azure, Name::Beige, Name::Bisque, Name::Black, Name::Blanchedalmond, Name::Blue, Name::Blueviolet, Name::Brown, Name::Burlywood, Name::Cadetblue,
  Name::Chartreuse, Name::Chocolate, Name::Coral, Name::Cornflowerblue, Name::Cornsilk, Name::Crimson, Name::Cyan, Name::Darkblue, Name::Darkcyan, Name::Darkgoldenrod, Name::Darkgray, Name::Darkgreen, Name::Darkgrey, Name::Darkkhaki,
  Name::Darkmagenta, Name::Darkolivegreen, Name::Darkorange, Name::Darkorchid, Name::Darkred, Name::Darksalmon, Name::Darkseagreen, Name::Darkslateblue, Name::Darkslategray, Name::Darkslategrey, Name::Darkturquoise, Name::Darkviolet, Name::Deeppink, Name::Deepskyblue,
  Name::Dimgray, Name::Dimgrey, Name::Dodgerblue, Name::Firebrick, Name::Floralwhite, Name::Forestgreen, Name::Fuchsia, Name::Gainsboro, Name::Ghostwhite, Name::Gold, Name::Goldenrod, Name::Gray, Name::Green, Name::Greenyellow,
  Name::Grey, Name::Honeydew, Name::Hotpink, Name::Indianred, Name::Indigo, Name::Ivory, Name::Khaki, Name::Lavender, Name::Lavenderblush, Name::Lawngreen, Name::Lemonchiffon, Name::Lightblue, Name::Lightcoral, Name::Lightcyan,
  Name::Lightgoldenrodyellow, Name::Lightgray, Name::Lightgreen, Name::Lightgrey, Name::Lightpink, Name::Lightsalmon, Name::Lightseagreen, Name::Lightskyblue, Name::Lightslategray, Name::Lightslategrey, Name::Lightsteelblue, Name::Lightyellow, Name::Lime, Name::Limegreen,
  Name::Linen, Name::Magenta, Name::Maroon, Name::Mediumaquamarine, Name::Mediumblue, Name::Mediumorchid, Name::Mediumpurple, Name::Mediumseagreen, Name::Mediumslateblue, Name::Mediumspringgreen, Name::Mediumturquoise, Name::Mediumvioletred, Name::Midnightblue, Name::Mintcream,
  Name::Mistyrose, Name::Moccasin, Name::Navajowhite, Name::Navy, Name::Oldlace, Name::Olive, Name::Olivedrab, Name::Orange, Name::Orangered, Name::Orchid, Name::Palegoldenrod, Name::Palegreen, Name::Paleturquoise, Name::Palevioletred,
  Name::Papayawhip, Name::Peachpuff, Name::Peru, Name::Pink, Name::Plum, Name::Powderblue, Name::Purple, Name::Red, Name::Rosybrown, Name::Royalblue, Name::Saddlebrown, Name::Salmon, Name::Sandybrown, Name::Seagreen,
  Name::Seashell, Name::Sienna, Name::Silver, Name::Skyblue, Name::Slateblue, Name::Slategray, Name::Slategrey, Name::Snow, Name::Springgreen, Name::Steelblue, Name::Tan, Name::Teal, Name::Thistle, Name::Tomato,
  Name::Turquoise, Name::Violet, Name::Wheat, Name::White, Name::Whitesmoke, Name::Yellow, Name::Yellowgreen
}
 Named colors (same as SVG color keywords). More...
 

Public Member Functions

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

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. More...
 

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 205 of file graphics.h.

Member Enumeration Documentation

◆ Name

enum ogdf::Color::Name
strong

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 210 of file graphics.h.

Constructor & Destructor Documentation

◆ Color() [1/6]

ogdf::Color::Color ( )
inline

Creates an opaque black color.

Definition at line 361 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 364 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 367 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 373 of file graphics.h.

◆ Color() [6/6]

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

Crates a color from string str.

Definition at line 376 of file graphics.h.

Member Function Documentation

◆ alpha() [1/2]

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

Returns the alpha channel.

Definition at line 388 of file graphics.h.

◆ alpha() [2/2]

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

Sets the alpha channel to a.

Definition at line 400 of file graphics.h.

◆ blue() [1/2]

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

Returns the blue component.

Definition at line 385 of file graphics.h.

◆ blue() [2/2]

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

Sets the blue component to b.

Definition at line 397 of file graphics.h.

◆ fromString()

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

Sets the color the the color defined by str.

◆ green() [1/2]

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

Returns the green component.

Definition at line 382 of file graphics.h.

◆ green() [2/2]

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

Sets the green component to g.

Definition at line 394 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 419 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 414 of file graphics.h.

◆ red() [1/2]

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

Returns the red component.

Definition at line 379 of file graphics.h.

◆ red() [2/2]

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

Sets the red component to r.

Definition at line 391 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 Function 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 424 of file graphics.h.

Member Data Documentation

◆ m_alpha

uint8_t ogdf::Color::m_alpha
private

Definition at line 206 of file graphics.h.

◆ m_blue

uint8_t ogdf::Color::m_blue
private

Definition at line 206 of file graphics.h.

◆ m_green

uint8_t ogdf::Color::m_green
private

Definition at line 206 of file graphics.h.

◆ m_red

uint8_t ogdf::Color::m_red
private

Definition at line 206 of file graphics.h.


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