![]() |
Home | Libraries | People | FAQ | More |
The project supports any RGB color, as well as a number of constants that are named by the SVG standard.
svg_color_constant is simply
an enumerated list. The colors are defined here.
The list contains all of your expected colors, such as black and red. The
list contains one extra color element, blank,
used when you need to pass a color, but would not like it to show up. This
comes in handy for defining defaults for functions, for example.
using namespace boost::svg; svg_2d_plot my_plot; svg_color_constant my_const = red; my_plot.background_border_color(my_const); my_plot.background_color(lightgray);
![]() |
Note |
|---|---|
|
svg_color my_color = red; does not work. | |
You can define a svg_color
using two different constructors
// The parameters are red, green, and blue respectively. svg_color(int, int, int); // Use a pre-existing color constant. svg_color(svg_color_constant);
![]() |
Important |
|---|---|
Any integer value is accepted by the SVG standard, but negative values are rounded to 0, and positive values > 255 are rounded down to 255. | |
using namespace boost::svg; svg_color my_white(255, 255, 255); svg_color const_white(white); BOOST_ASSERT(my_white == const_white);
![]() |
Note |
|---|---|
| |
Constants are defined in an enum, svg_color_constant,
in alphabetical order. This facilitates quick lookup of their RGB values
from an array. Anywhere that a svg_color
can be used, a svg_color_constant
can be used, as the conversion is implicit.
All color information is stored in RGB format in a svg_color
struct. The rationale for storing information in RGB format is because it
is precise, and is always representable the exact same way. Storing a floating
point percentage introduces the possibility of rounding error, which I would
like to avoid at all costs.
| Copyright © 2007 Jake Voytko |