Reference » Service classes » MColor

Elgrint::MColor class

Declared in MColor.h

Description

Describes an RGBA color value with up to 56-bit color depth.
Read more...

MColor

Initializers:

Name Description
MColor() Default constructor. Sets this to NoneColor.
MColor(r,g,b,a) Init constructor. Sets each of the RGBA channels to a value specified by the corresponding parameter.
MColor(r,g,b,a) Init constructor. Sets each of the RGBA channels to a value specified by the corresponding parameter.

Mutators:

Name Description
setA(a) Changes the alpha channel value to a (forcing it to the [0..255] integral range).
setB(B) Changes the blue channel value to B (forcing it to the [0..256) integral range).
setB(b) Changes the blue channel value to b (forcing it to the [0..255] integral range).
setG(G) Changes the green channel value to G (forcing it to the [0..256) integral range).
setG(g) Changes the green channel value to g (forcing it to the [0..255] integral range).
setR(R) Changes the red channel value to R (forcing it to the [0..256) range).
setR(r) Changes the red channel value to r (forcing it to the [0..255] integral range).

Revealers:

Name Description
B() Returns the full blue channel value [0..256). More precise but less efficient than b.
G() Returns the full green channel value [0..256). More precise but less efficient than g.
H() Returns the precise hue of this color [0..360).
L() Returns the precise lightness of this color [0..256).
R() Returns the full red channel value [0..256). More precise but less efficient than r.
S() Returns the precise saturation of this color [0..256).
a() Returns the alpha channel value [0..255], but never 127 (see setA for details).
b() Returns the integral blue channel value [0..255]. More efficient than B.
g() Returns the integral green channel value [0..255]. More efficient than G.
operator!=(c) The logical opposite of the operator==.
operator==(c) Returns true iff this is equal to c.
r() Returns the integral red channel value [0..255]. More efficient than R.

Converters:

Name Description
grayscale() Returns the grayscale representation of this color.
inverse() Returns the color which is an inverse (complement) of this.
operator+(c) Mixes two colors together.
operator+(d) Returns the color whose "brightness" is increased by d units compared to this.
operator-(d) Returns the color whose "brightness" is decreased by d units compared to this.

Global functions:

Name Description
ConvHSLToRGB(H,S,L) Creates an extended RGB color based on the HSL (Hue, Saturation, Lightness) color coordinates.

Details

MColor specifies a color value with 4 color RGBA channels: Red, Green, Blue, and Alpha.

The Alpha (aka transparency) channel is 8 bits wide, i.e. can have 255 distinct integral values, from 0 through 255, with 127 being reserved for internal use (see setA). The value of 0 indicates complete transparency (no visible color), and 255 - complete opaqueness (solid color).

The Red, Green, and Blue channels are 16-bit wide, i.e. can have 65536 distinct values, specified as float variables with values from 0 and up to, but not including 256, and the floating point precision is 1/256 or about 0.004 (See Remarks). Note that, for instance, 200.001 and 200.002 are considered to be the same value, because they are both mapped to the same 16-bit precision value. For all three channels, the value of 0 indicates no brightness, and 255.996 - full brightness (actually, anything from 255 and higher is considered full brightness).

'MColor' is used as a pixel value for MImage and by various functions throughout Elgrint. Its methods can manipulate the color value in a way suitable for window classes' purposes.

'MColor' can be converted from RGBA to HSLA (Hue, Saturation, Lightness, Alpha) format, using its H, S, and L revealers (the alpha value remains the same). The opposite conversion is done via the global ConvHSLToRGB function. The HSL color space is also described in the above illustration. It is sometimes more useful and convenient than RGB.

Remarks

Example

Let us know

Please Contact us to report any errors on this page, or to suggest any improvements.

Miranor Home | About Miranor | About Elgrint | Create account | Login | Account settings | Contact Us | Privacy Policy | Site map

© Copyright 2014 by Miranor. All rights reserved. By using this site you agree to the Terms of Use.

Page last updated on August 10th, 2014.