Colors represented as RGBA values. More...
#include <ogdf/basic/graphics.h>
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 . | |
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.
|
strong |
Named colors (same as SVG color keywords).
Definition at line 165 of file graphics.h.
|
inline |
Creates an opaque black color.
Definition at line 316 of file graphics.h.
Creates a color from given RGBA-values.
Definition at line 319 of file graphics.h.
Creates a color from given RGBA-values.
Definition at line 323 of file graphics.h.
ogdf::Color::Color | ( | Color::Name | name | ) |
Creates a color from given color name name
.
|
inline |
Crates a color from string str
.
Definition at line 330 of file graphics.h.
Crates a color from string str
.
Definition at line 333 of file graphics.h.
|
inline |
Returns the alpha channel.
Definition at line 345 of file graphics.h.
Sets the alpha channel to a
.
Definition at line 357 of file graphics.h.
|
inline |
Returns the blue component.
Definition at line 342 of file graphics.h.
Sets the blue component to b
.
Definition at line 354 of file graphics.h.
Sets this color to the color defined by str
.
str | string of the form "#rgb" or "#rrggbb" |
|
inline |
Returns the green component.
Definition at line 339 of file graphics.h.
Sets the green component to g
.
Definition at line 351 of file graphics.h.
Returns true iff c
and this color differ in any component.
Definition at line 382 of file graphics.h.
Returns true iff c
and this color are equal in every component.
Definition at line 377 of file graphics.h.
|
inline |
Returns the red component.
Definition at line 336 of file graphics.h.
Sets the red component to r
.
Definition at line 348 of file graphics.h.
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).
Writes the string representation of color c
to output stream os
.
Definition at line 385 of file graphics.h.
|
private |
Definition at line 161 of file graphics.h.
|
private |
Definition at line 161 of file graphics.h.
|
private |
Definition at line 161 of file graphics.h.
|
private |
Definition at line 161 of file graphics.h.