Magick::Color Class
Author: Bob Friesenhahn
Description: Magick::Color class documentation

# Magick::Color

Color is the base color class in Magick++. It is a simple container class for the raw red, green, and blue values scaled to a depth of 16 bits. Normally users will instantiate a class derived from Color which supports the color model that fits the needs of the application. The Color class may be constructed directly from an X11-style color string.

Available derived color specification classes are shown in the following table:

Color Derived Classes
ColorRGB | Representation of RGB color with red, green, and blue specified as ratios (0 to 1)
ColorGray | Representation of grayscale RGB color (equal parts red, green, and blue) specified as a ratio (0 to 1)
ColorMono | Representation of a black/white color (true/false)
ColorYUV | Representation of a color in the YUV colorspace

Base color class stores RGB components scaled to fit ColorType (16 bits)

### Color Class

The Color base class is not intended to be used directly. Normally a user will construct a derived class or inherit from this class. Color arguments must be scaled to the ColorType size (16 bits). The ScaleDoubleToQuantum and ScaleQuantumToDouble macros can aid with this task.

An alternate way to contruct the class is via an X11-compatable color specification string.

`class Color`
`{`
`friend class Image;`
`public:`
`Color ( ColorType red_, ColorType green_, ColorType blue_ );`
`Color ( const std::string x11color_ );`
`Color ( const char * x11color_ );`
`Color ( void );`
`virtual ~Color ( void );`

`// Does object contain valid color?`
`void isValid ( bool valid_ );`
`bool isValid ( void ) const;`

`// Set color via X11 color specification string`
`const Color& operator = ( std::string x11color_ );`
`const Color& operator = ( const char * x11color_ );`

`// Return X11 color specification string`
`/* virtual */ operator std::string() const;`

`protected:`

`void redQuantum ( ColorType red_ );`
`ColorType redQuantum ( void ) const;`

`void greenQuantum ( ColorType green_ );`
`ColorType greenQuantum ( void ) const;`

`void blueQuantum ( ColorType blue_ );`
`ColorType blueQuantum ( void ) const;`

`};`

### ColorRGB

Representation of an RGB color. All color arguments have a valid range of 0.0 - 1.0.

`class ColorRGB : public Color`
`{`
`public:`
`ColorRGB ( double red_, double green_, double blue_ );`
`ColorRGB ( const string x11color_ );`
`ColorRGB ( void );`
`/* virtual */ ~ColorRGB ( void );`

`void red ( double red_ );`
`double red ( void ) const;`

`void green ( double green_ );`
`double green ( void ) const;`

`void blue ( double blue_ );`
`double blue ( void ) const;`
`};`

### ColorGray

Representation of a grayscale color (in RGB colorspace). Grayscale is simply RGB with equal parts of red, green, and blue. All double arguments have a valid range of 0.0 - 1.0.

`class ColorGray : public Color`
`{`
`public:`
`ColorGray ( double shade_ );`
`ColorGray ( void );`
`/* virtual */ ~ColorGray ();`

`void shade ( double shade_ );`
`double shade ( void ) const;`
`};`

### ColorMono

Representation of a black/white pixel (in RGB colorspace). Color arguments are constrained to 'false' (black pixel) and 'true' (white pixel).

`class ColorMono : public Color`
`{`
`public:`
`ColorMono ( bool mono_ );`
`ColorMono ( void );`
`/* virtual */ ~ColorMono ();`

`void mono ( bool mono_ );`
`bool mono ( void ) const;`

`};`

### ColorHSL

Representation of a color in Hue/Saturation/Luminosity (HSL) colorspace.

`class ColorHSL : public Color`
`{`
`public:`
`ColorHSL ( double hue_, double saturation_, double luminosity_ );`
`ColorHSL ( );`
`/* virtual */ ~ColorHSL ( );`

`void hue ( double hue_ );`
`double hue ( void ) const;`

`void saturation ( double saturation_ );`
`double saturation ( void ) const;`

`void luminosity ( double luminosity_ );`
`double luminosity ( void ) const;`
`};`

### ColorYUV

Representation of a color in YUV colorspace (used to encode color for television transmission).

Argument ranges:
Y: 0.0 through 1.0
U: -0.5 through 0.5
V: -0.5 through 0.5

`class ColorYUV : public Color`
`{`
`public:`
`ColorYUV ( double y_, double u_, double v_ );`
`ColorYUV ( void );`
`/* virtual */ ~ColorYUV ( void );`

`void u ( double u_ );`
`double u ( void ) const;`

`void v ( double v_ );`
`double v ( void ) const;`

`void y ( double y_ );`
`double y ( void ) const;`
`};`