AGG lesson 5 RGB Color definition
Mixers exist to accommodate different pixel formats for different platforms and different needs. There are three types of mixers: agg::rgba, agg:: rgba8, and agg:: rgba16, which are used to specify colors, rgba is stored as double per channel, rgba8 is unsigned char, and rgba16 is int or long int; mixers function like RGB and COLORREF macros in the Win32API.
Special note for agg::rgba: Although each component is stored using double type, in fact, the value interval is [0,1], and the value of each component of agg::rgba8 is [0,255]
header #include "agg_pixfmt_rgba.h"
type definition
struct rgba8; //Yes, you are not mistaken, it is a structure, not a class…
elementary member function
rgba8(unsigned r, unsigned g, unsigned b,unsigned a)
No need to explain it, maximum 255;
clear(), no_color()
All four channels are cleared, that is, they become colorless.
transparent()
alpha cleared, transparent;
opacity()
Returns transparency, represented by double;
gradient(agg::rgba8 &c, double k)
Color gradient, that is, the color changes from the original color gradually to c, the rate of change is k;
add(agg::rgba8 &c, unsinged cover)
Color Overlay, superimposing a color c with transparency of cover/255;
member variables
r, g, b, a are unsigned integers;