KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
kjb::PixelHSVA Struct Reference

Alternative Pixel using hue, saturation, value, and opacity (alpha). More...

#include <i_hsv.h>

Inheritance diagram for kjb::PixelHSVA:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

kjb::PixelHSVA::PixelHSVA ( )
inline

Default ctor, which leaves all fields uninitialized.

Warning
"Uninitialized" often means "bug-causing" and "troublesome."
kjb::PixelHSVA::PixelHSVA ( const kjb_c::Pixel &  p)
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.

Parameters
hhHue, a value from 0 to 1. 0 = red, .3 = green, .6 = blue.
ssSaturation, range 0 to 1. 0 = gray, 1 = very vivid
vvValue, range 0 to 1. 0 = black, 1 = bright
aaAlpha 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.

Member Function Documentation

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).

float kjb::PixelHSVA::get_hue ( ) const
inline

get hue (in range 0-1) but please consider using get_hsv().

float kjb::PixelHSVA::get_saturation ( ) const
inline

get saturation (in range 0-1) but please consider get_hsv().

float kjb::PixelHSVA::get_value ( ) const
inline

get value (in range 0-1) but please consider using get_hsv().


The documentation for this struct was generated from the following files: