A class to transform RGBA color to HSV, HSL and CMYK. More...
#include <ColorTransform.h>
Public Types | |
enum | Spec { Invalid, Rgb, Hsv, Cmyk, Hsl } |
Public Member Functions | |
Initializer Methods | |
Methods related to instantiation and destruction. | |
ColorTransform () | |
Default constructor of a new color. More... | |
ColorTransform (const ColorTransform &colt) | |
It initializes a new with the given color transform. More... | |
ColorTransform (const RGBAColor &color) | |
It initializes a new color with the given RGBAColor. More... | |
ColorTransform (const int &rgba) | |
It initializes a new color with the given rgba value. More... | |
ColorTransform (const int r, const int g, const int b, const int a=255) | |
It initializes a new color. More... | |
~ColorTransform () | |
Destructor. More... | |
te::color::ColorTransform & | operator= (const ColorTransform &colt) |
Assigns a copy of a color transform and returns a reference to it. More... | |
void | setRgba (int r, int g, int b, int a) |
It sets the color. More... | |
void | setRgba (int rgba) |
It sets the color. More... | |
void | setColor (const RGBAColor &cor) |
It sets the color. More... | |
void | getRgba (int *r, int *g, int *b, int *a=0) const |
It gets the color value. More... | |
int | getRgba () const |
It returns the color value (0xAARRGGBB). More... | |
te::color::RGBAColor | getColor () const |
It returns the RGBA color. More... | |
int | getRed () const |
It returns the red component. More... | |
int | getGreen () const |
It returns the green component. More... | |
int | getBlue () const |
It returns the blue component. More... | |
int | getAlpha () const |
It returns the alpha component. More... | |
void | setRed (int red) |
It sets the red component. More... | |
void | setGreen (int green) |
It sets the green component. More... | |
void | setBlue (int blue) |
It sets the blue component. More... | |
void | setAlpha (int alpha) |
It sets the alpha component. More... | |
te::color::ColorTransform | toRgb () const |
It returns the color tranform in Rgb spec. More... | |
te::color::ColorTransform | toHsv () const |
It returns the color tranform in Hsv spec. More... | |
te::color::ColorTransform | toHsl () const |
It returns the color tranform in Hsl spec. More... | |
te::color::ColorTransform | toCmyk () const |
It returns the color tranform in Cmyk spec. More... | |
int | getHsvHue () const |
It returns the hue component of this color. More... | |
int | getHsvSaturation () const |
It returns the saturation component of this color. More... | |
int | getValue () const |
It returns the value component of this color. More... | |
void | getHsv (int *h, int *s, int *v, int *a=0) const |
It gets the h, s, v components of this color. More... | |
void | setHsv (int h, int s, int v, int a=255) |
It sets the h, s, v components of this color. More... | |
int | getCyan () const |
It gets the cyan component of this color. More... | |
int | getMagenta () const |
It gets the magenta component of this color. More... | |
int | getYellow () const |
It gets the yellow component of this color. More... | |
int | getBlack () const |
It gets the black component of this color. More... | |
void | getCmyk (int *c, int *m, int *y, int *k, int *a=0) |
It gets the c, m, y, k components of this color. More... | |
void | setCmyk (int c, int m, int y, int k, int a=255) |
It sets the c, m, y, k components of this color. More... | |
int | getHslHue () const |
It returns the hue component of this color. More... | |
int | getHslSaturation () const |
It returns the saturation component of this color. More... | |
int | getLightness () const |
It returns the lightness component of this color. More... | |
void | getHsl (int *h, int *s, int *l, int *a=0) const |
It gets the h, s, l components of this color. More... | |
void | setHsl (int h, int s, int l, int a=255) |
It sets the h, s, l components of this color. More... | |
bool | operator== (const ColorTransform &colt) const |
It compares the color tranforms are iqual. More... | |
bool | operator!= (const ColorTransform &colt) const |
It compares the color tranforms are different. More... | |
Private Member Functions | |
bool | fuzzyCompare (double p1, double p2) const |
It compares the double valuea are iqual. More... | |
bool | fuzzyIsNull (double d) const |
It verifies the double is null. More... | |
void | invalidate () |
Marks the color transform as invalid and sets all components to zero (alpha is set to fully opaque). More... | |
bool | isValid () const |
It checks if the color is valid. More... | |
int | round (double d) const |
It rounds the double value to int value. More... | |
template<typename T > | |
const T & | vMin (const T &a, const T &b) const |
Private Attributes | |
union { | |
struct { | |
unsigned short alpha | |
unsigned short black | |
unsigned short cyan | |
unsigned short magenta | |
unsigned short yellow | |
} acmyk | |
struct { | |
unsigned short alpha | |
unsigned short hue | |
unsigned short lightness | |
unsigned short pad | |
unsigned short saturation | |
} ahsl | |
struct { | |
unsigned short alpha | |
unsigned short hue | |
unsigned short pad | |
unsigned short saturation | |
unsigned short value | |
} ahsv | |
struct { | |
unsigned short alpha | |
unsigned short blue | |
unsigned short green | |
unsigned short pad | |
unsigned short red | |
} argb | |
unsigned short array [5] | |
} | m_params |
Spec | m_spec |
A class to transform RGBA color to HSV, HSL and CMYK.
Definition at line 50 of file ColorTransform.h.
Enumerator | |
---|---|
Invalid | |
Rgb | |
Hsv | |
Cmyk | |
Hsl |
Definition at line 54 of file ColorTransform.h.
te::color::ColorTransform::ColorTransform | ( | ) |
Default constructor of a new color.
te::color::ColorTransform::ColorTransform | ( | const ColorTransform & | colt | ) |
It initializes a new with the given color transform.
colt | The color transform. |
te::color::ColorTransform::ColorTransform | ( | const RGBAColor & | color | ) |
te::color::ColorTransform::ColorTransform | ( | const int & | rgba | ) |
It initializes a new color with the given rgba value.
rgba | The rgba value. |
te::color::ColorTransform::ColorTransform | ( | const int | r, |
const int | g, | ||
const int | b, | ||
const int | a = 255 |
||
) |
It initializes a new color.
r | Red component (range from 0 to 255). |
g | Green component (range from 0 to 255). |
b | Blue component (range from 0 to 255). |
a | Alpha component. A range from 0 to 255 (see the macro TE_OPAQUE and TE_TRANSPARENT for the values of totally transparent and totally opaque). |
te::color::ColorTransform::~ColorTransform | ( | ) |
Destructor.
|
inlineprivate |
It compares the double valuea are iqual.
p1 | First value. |
p2 | Second value. |
Definition at line 524 of file ColorTransform.h.
References vMin().
|
inlineprivate |
It verifies the double is null.
d | Value to be verified. |
Definition at line 529 of file ColorTransform.h.
int te::color::ColorTransform::getAlpha | ( | ) | const |
It returns the alpha component.
int te::color::ColorTransform::getBlack | ( | ) | const |
It gets the black component of this color.
int te::color::ColorTransform::getBlue | ( | ) | const |
It returns the blue component.
void te::color::ColorTransform::getCmyk | ( | int * | c, |
int * | m, | ||
int * | y, | ||
int * | k, | ||
int * | a = 0 |
||
) |
It gets the c, m, y, k components of this color.
c | The cyan component. |
m | The magenta component. |
y | The yellow component. |
k | The black component. |
a | The alpha component. |
te::color::RGBAColor te::color::ColorTransform::getColor | ( | ) | const |
It returns the RGBA color.
int te::color::ColorTransform::getCyan | ( | ) | const |
It gets the cyan component of this color.
int te::color::ColorTransform::getGreen | ( | ) | const |
It returns the green component.
void te::color::ColorTransform::getHsl | ( | int * | h, |
int * | s, | ||
int * | l, | ||
int * | a = 0 |
||
) | const |
It gets the h, s, l components of this color.
h | The cyan component. |
s | The magenta component. |
l | The yellow component. |
a | The alpha component. |
int te::color::ColorTransform::getHslHue | ( | ) | const |
It returns the hue component of this color.
int te::color::ColorTransform::getHslSaturation | ( | ) | const |
It returns the saturation component of this color.
void te::color::ColorTransform::getHsv | ( | int * | h, |
int * | s, | ||
int * | v, | ||
int * | a = 0 |
||
) | const |
It gets the h, s, v components of this color.
h | The hue component. |
s | The saturation component. |
v | The value component. |
a | The alpha component. |
int te::color::ColorTransform::getHsvHue | ( | ) | const |
It returns the hue component of this color.
int te::color::ColorTransform::getHsvSaturation | ( | ) | const |
It returns the saturation component of this color.
int te::color::ColorTransform::getLightness | ( | ) | const |
It returns the lightness component of this color.
int te::color::ColorTransform::getMagenta | ( | ) | const |
It gets the magenta component of this color.
int te::color::ColorTransform::getRed | ( | ) | const |
It returns the red component.
void te::color::ColorTransform::getRgba | ( | int * | r, |
int * | g, | ||
int * | b, | ||
int * | a = 0 |
||
) | const |
It gets the color value.
r | Red component. |
g | Green component. |
b | Blue component. |
a | Alpha component. |
int te::color::ColorTransform::getRgba | ( | ) | const |
It returns the color value (0xAARRGGBB).
int te::color::ColorTransform::getValue | ( | ) | const |
It returns the value component of this color.
int te::color::ColorTransform::getYellow | ( | ) | const |
It gets the yellow component of this color.
|
inlineprivate |
Marks the color transform as invalid and sets all components to zero (alpha is set to fully opaque).
Definition at line 504 of file ColorTransform.h.
|
inlineprivate |
It checks if the color is valid.
Definition at line 514 of file ColorTransform.h.
bool te::color::ColorTransform::operator!= | ( | const ColorTransform & | colt | ) | const |
It compares the color tranforms are different.
colt | The color transform to be compared. |
te::color::ColorTransform& te::color::ColorTransform::operator= | ( | const ColorTransform & | colt | ) |
Assigns a copy of a color transform and returns a reference to it.
color | The color transfom to be copied. |
bool te::color::ColorTransform::operator== | ( | const ColorTransform & | colt | ) | const |
It compares the color tranforms are iqual.
colt | The color transform to be compared. |
|
inlineprivate |
It rounds the double value to int value.
Definition at line 519 of file ColorTransform.h.
void te::color::ColorTransform::setAlpha | ( | int | alpha | ) |
It sets the alpha component.
void te::color::ColorTransform::setBlue | ( | int | blue | ) |
It sets the blue component.
void te::color::ColorTransform::setCmyk | ( | int | c, |
int | m, | ||
int | y, | ||
int | k, | ||
int | a = 255 |
||
) |
It sets the c, m, y, k components of this color.
c | The cyan component. |
m | The magenta component. |
y | The yellow component. |
k | The black component. |
a | The alpha component. |
void te::color::ColorTransform::setColor | ( | const RGBAColor & | cor | ) |
It sets the color.
cor | The RGBA color. |
void te::color::ColorTransform::setGreen | ( | int | green | ) |
It sets the green component.
void te::color::ColorTransform::setHsl | ( | int | h, |
int | s, | ||
int | l, | ||
int | a = 255 |
||
) |
It sets the h, s, l components of this color.
h | The cyan component. |
s | The magenta component. |
l | The yellow component. |
a | The alpha component. |
void te::color::ColorTransform::setHsv | ( | int | h, |
int | s, | ||
int | v, | ||
int | a = 255 |
||
) |
It sets the h, s, v components of this color.
h | The hue component. |
s | The saturation component. |
v | The value component. |
a | The alpha component. |
void te::color::ColorTransform::setRed | ( | int | red | ) |
It sets the red component.
void te::color::ColorTransform::setRgba | ( | int | r, |
int | g, | ||
int | b, | ||
int | a | ||
) |
It sets the color.
r | Red component (range from 0 to 255). |
g | Green component (range from 0 to 255). |
b | Blue component (range from 0 to 255). |
a | Alpha component. A range from 0 to 255 (see the macro TE_OPAQUE and TE_TRANSPARENT for the values of totally transparent and totally opaque). |
void te::color::ColorTransform::setRgba | ( | int | rgba | ) |
It sets the color.
rgba | The color represented by a number of 4 bytes, where the values ??are in the following order: alpha, red, green and blue. The alpha is the most significant byte. |
te::color::ColorTransform te::color::ColorTransform::toCmyk | ( | ) | const |
It returns the color tranform in Cmyk spec.
te::color::ColorTransform te::color::ColorTransform::toHsl | ( | ) | const |
It returns the color tranform in Hsl spec.
te::color::ColorTransform te::color::ColorTransform::toHsv | ( | ) | const |
It returns the color tranform in Hsv spec.
te::color::ColorTransform te::color::ColorTransform::toRgb | ( | ) | const |
It returns the color tranform in Rgb spec.
|
inlineprivate |
Definition at line 456 of file ColorTransform.h.
Referenced by fuzzyCompare().
struct { ... } te::color::ColorTransform::acmyk |
struct { ... } te::color::ColorTransform::ahsl |
struct { ... } te::color::ColorTransform::ahsv |
unsigned short te::color::ColorTransform::alpha |
Definition at line 466 of file ColorTransform.h.
struct { ... } te::color::ColorTransform::argb |
unsigned short te::color::ColorTransform::array[5] |
Definition at line 500 of file ColorTransform.h.
unsigned short te::color::ColorTransform::black |
Definition at line 488 of file ColorTransform.h.
unsigned short te::color::ColorTransform::blue |
Definition at line 469 of file ColorTransform.h.
unsigned short te::color::ColorTransform::cyan |
Definition at line 485 of file ColorTransform.h.
unsigned short te::color::ColorTransform::green |
Definition at line 468 of file ColorTransform.h.
unsigned short te::color::ColorTransform::hue |
Definition at line 476 of file ColorTransform.h.
unsigned short te::color::ColorTransform::lightness |
Definition at line 496 of file ColorTransform.h.
union { ... } te::color::ColorTransform::m_params |
Referenced by invalidate().
|
private |
Definition at line 460 of file ColorTransform.h.
Referenced by invalidate(), and isValid().
unsigned short te::color::ColorTransform::magenta |
Definition at line 486 of file ColorTransform.h.
unsigned short te::color::ColorTransform::pad |
Definition at line 470 of file ColorTransform.h.
unsigned short te::color::ColorTransform::red |
Definition at line 467 of file ColorTransform.h.
unsigned short te::color::ColorTransform::saturation |
Definition at line 477 of file ColorTransform.h.
unsigned short te::color::ColorTransform::value |
Definition at line 478 of file ColorTransform.h.
unsigned short te::color::ColorTransform::yellow |
Definition at line 487 of file ColorTransform.h.