KJB
|
Alternative Pixel using hue, saturation, value, and opacity (alpha). More...
#include <i_hsv.h>
Public Member Functions | |
PixelHSVA () | |
Default ctor, which leaves all fields uninitialized. More... | |
PixelHSVA (const kjb_c::Pixel &p) | |
This builds a valid pixel from another. More... | |
PixelHSVA (float hh, float ss, float vv, float aa=1.0f) | |
This builds a valid pixel with given values for color channels. More... | |
void | get_hsv (float *, float *, float *) const |
get hue, saturation, value (each in range 0-1 if 0<=r,g,b<=255). More... | |
float | get_hue () const |
get hue (in range 0-1) but please consider using get_hsv(). More... | |
float | get_saturation () const |
get saturation (in range 0-1) but please consider get_hsv(). More... | |
float | get_value () const |
get value (in range 0-1) but please consider using get_hsv(). More... | |
Alternative Pixel using hue, saturation, value, and opacity (alpha).
This is an adaptation of struct kjb_c::Pixel that adapts that type for an interface based on hue, saturation, and value.
Hue is a value from 0 to 1 that cyclically moves through a sort of rainbow of colors. 0 = red, 0.33 = green, 0.67 = blue. In other contexts, hue is often represented as an angle h from 0 to 360 deg. Hue, in this context, then equals h/360.
Saturation is a value from 0 to 1 represents the vividness of the color. Saturation = 0 corresponds to achromatic colors: shades of gray. Saturation = 1 is a very vivid color.
Value represents brightness. Value = 0 is black, and Value = 1 is bright.
Alpha represents opacity; 0 is transparent, 1 is opaque.
The formulas used are from the following article: http://en.wikipedia.org/w/index.php?title=HSL_and_HSV&oldid=423114768
All the above values range from 0 to 1 in the HSVA interface (including alpha), and they are transformed to RGBA values ranging from 0 to 255 (including alpha).
This struct assumes the user is not interested in the "Invalid Pixel" structure.
|
inline |
Default ctor, which leaves all fields uninitialized.
|
inline |
This builds a valid pixel from another.
Build a pixel from another. It receives a kjb_c::Pixel so as to work with PixelRGBA as well.
kjb::PixelHSVA::PixelHSVA | ( | float | hh, |
float | ss, | ||
float | vv, | ||
float | aa = 1.0f |
||
) |
This builds a valid pixel with given values for color channels.
hh | Hue, a value from 0 to 1. 0 = red, .3 = green, .6 = blue. |
ss | Saturation, range 0 to 1. 0 = gray, 1 = very vivid |
vv | Value, range 0 to 1. 0 = black, 1 = bright |
aa | Alpha opacity, 0 to 1. 0 = transparent, 1 = opaque. |
Once you construct a pixel this way, internally we store r, g, b channels which are related to hh, ss, vv by a messy nonlinear xform.
void kjb::PixelHSVA::get_hsv | ( | float * | ph, |
float * | ps, | ||
float * | pv | ||
) | const |
get hue, saturation, value (each in range 0-1 if 0<=r,g,b<=255).
|
inline |
get hue (in range 0-1) but please consider using get_hsv().
|
inline |
get saturation (in range 0-1) but please consider get_hsv().
|
inline |
get value (in range 0-1) but please consider using get_hsv().