Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::ColorSpace Class Reference

A class for managing all the color transformations between different color spaces. More...

#include <vcf/GraphicsKit/Color.h>

List of all members.

Public Types

enum  { RGBMax = 0xFF, HSLMax = 0xF0, RGBMax16 = 0xFFFF, HSLMax16 = 0xF0F0 }
enum  { hue_undefined = HUE_UNDEFINED }

Static Public Member Functions

static int getLuminosity (const Color &color)
 compute the luminosity for an RGB color.
static void setLuminosity (Color &color, const int &luminosity)
 set the luminosity of a color.
static double HueToColorValue (const double Hue, const double M1, const double M2)
 helper function
static HSVtype RGBToHSV (const RGBtype &RGB)
static RGBtype HSVToRGB (const HSVtype &HSV)
static RGBtype HSLToRGB (const HSLtype &hsl)
static HSLtype RGBToHSL (const RGBtype &rgb)
static HWBtype RGBToHWB (const RGBtype &rgb)
static RGBtype HWBToRGB (const HWBtype &HWB)
static HSLtype HSLRangeToHSL (const HSLrangetype &hslRange)
static HSLrangetype HSLToHSLRange (const HSLtype &hsl)
static uint32 RGBToColorLong (const RGBtype &rgb)
static RGBtype ColorLongToRGB (const uint32 color)
static uint32 HSLToColorLong (const HSLtype &hsl)
static HSLtype ColorLongToHSL (const uint32 color)
static RGBrangetype RGBToRGBRange (const RGBtype &rgb)
static RGBtype RGBRangeToRGB (const RGBrangetype &rgbRange)
static RGBtype HSLRangeToRGB (const HSLrangetype &hslRange)
static HSLrangetype RGBToHSLRange (const RGBtype &rgb)
static uint32 HSLRangeToColorLong (const HSLrangetype &hsl)
static HSLrangetype ColorLongToHSLRange (const uint32 color)
static Color RGBToColor (const RGBtype &rgb)
 inline implementation for ColorSpace class
static RGBtype ColorToRGB (const Color &color)
static uint32 ColorToColorLong (const Color &color)
static Color HSVToColor (const HSVtype &hsl)
static HSVtype ColorToHSV (const Color &rgb)
static Color HSLToColor (const HSLtype &hsl)
static HSLtype ColorToHSL (const Color &rgb)
static Color HWBToColor (const HWBtype &hsl)
static HWBtype ColorToHWB (const Color &rgb)
static double getChanged (const double &initialVal, const double &percent)
static void changeHSV (HSVtype &hsv, const double &percentH, const double &percentS, const double &percentV)
 It is suggested to call this function with colors: 0.0/ 0.0 / 0.71428571428571.
static void changeHSL (HSLtype &hsl, const double &percentH, const double &percentS, const double &percentL)
 It is suggested to call this function with colors: 0.0/ 0.0 / -0.71428571428571.
static void changeHWB (HWBtype &hsl, const double &percentH, const double &percentW, const double &percentB)
 It is suggested to call this function with colors: 0.0/ 0.0 / 0.71428571428571.
static HSVtype changeHSV (const HSVtype &hsv, const double &percentH, const double &percentS, const double &percentV)
static HSLtype changeHSL (const HSLtype &hsl, const double &percentH, const double &percentS, const double &percentL)
static HWBtype changeHWB (const HWBtype &hwb, const double &percentH, const double &percentW, const double &percentB)
static Color changeHSV (const Color &color, const double &percentH, const double &percentS, const double &percentV)
 Example: To draw the Titlebars of a window with a color gradient do the following:.
static Color changeHSL (const Color &color, const double &percentH, const double &percentS, const double &percentL)
static Color changeHWB (const Color &color, const double &percentH, const double &percentW, const double &percentB)
static void changeHue (HSLtype &hsl, const double &deltaH)
static HSLtype changeHue (const HSLtype &hsl, const double &deltaH)
static Color changeHue (const Color &color, const double &deltaH)
static RGBtype changeHue (const RGBtype &color, const double &deltaH)
static uint32 changeHue (const uint32 &color, const double &deltaH)

Static Public Attributes

static const double HueCriticalMax
 HueCriticalMax is assigned ( 1.0 - 1.0 / 6.0 ) Hue > HueCriticalMax => rgb.R > 1;.

Classes

struct  HSLrangetype
struct  HSLtype
struct  HSVtype
struct  HWBtype
struct  RGBrangetype
struct  RGBtype


Detailed Description

A class for managing all the color transformations between different color spaces.

ColorSpace interface

Hue Luminosity management

WebPages:

Abstract: The two most common color selector models, other than RGB (Red-Green-Blue), are the hue-based HSV (Hue-Saturation-Value) and HSL (Hue-Saturation-Lightness) color models. It is shown that both of these models are flawed. A closely related model, HWB (Hue-Whiteness-Blackness), is introduced that avoids the flaws, is slightly faster to compute, and is very easy to teach to new users: Choose a hue. Lighten it with white. Darken it with black. We explain that lightening is not the opposite of darkening.

Modified, with some fixes to the algorithms, by Marcello Pietrobon

Modified, by Jim Crafton, fixed some errors due to inclusion of Win32 types


Member Enumeration Documentation

anonymous enum
 

Enumerator:
RGBMax 
HSLMax 
RGBMax16 
HSLMax16 

anonymous enum
 

Enumerator:
hue_undefined 


Member Function Documentation

Color VCF::ColorSpace::changeHSL const Color color,
const double &  percentH,
const double &  percentS,
const double &  percentL
[inline, static]
 

ColorSpace::HSLtype VCF::ColorSpace::changeHSL const HSLtype hsl,
const double &  percentH,
const double &  percentS,
const double &  percentL
[inline, static]
 

static void VCF::ColorSpace::changeHSL HSLtype hsl,
const double &  percentH,
const double &  percentS,
const double &  percentL
[static]
 

It is suggested to call this function with colors: 0.0/ 0.0 / -0.71428571428571.

It is suggested to call this function with grays: 0.0/ 0.0 / -0.33333333333333

Color VCF::ColorSpace::changeHSV const Color color,
const double &  percentH,
const double &  percentS,
const double &  percentV
[inline, static]
 

Example: To draw the Titlebars of a window with a color gradient do the following:.

        Color color_right = color;

        // enabled window (color)
        Color color_left = changeHSL( color_right, 0.0, 0.0, -0.71428571428571 );

        // disable window (gray)
        Color color_left = changeHSL( color_right, 0.0, 0.0, -0.33333333333333 );
        drawGradientBackground(pc, color_left, color_right);

ColorSpace::HSVtype VCF::ColorSpace::changeHSV const HSVtype hsv,
const double &  percentH,
const double &  percentS,
const double &  percentV
[inline, static]
 

static void VCF::ColorSpace::changeHSV HSVtype hsv,
const double &  percentH,
const double &  percentS,
const double &  percentV
[static]
 

It is suggested to call this function with colors: 0.0/ 0.0 / 0.71428571428571.

It is suggested to call this function with grays: 0.0/ 0.0 / 0.33333333333333

uint32 VCF::ColorSpace::changeHue const uint32 color,
const double &  deltaH
[inline, static]
 

ColorSpace::RGBtype VCF::ColorSpace::changeHue const RGBtype color,
const double &  deltaH
[inline, static]
 

Color VCF::ColorSpace::changeHue const Color color,
const double &  deltaH
[inline, static]
 

ColorSpace::HSLtype VCF::ColorSpace::changeHue const HSLtype hsl,
const double &  deltaH
[inline, static]
 

static void VCF::ColorSpace::changeHue HSLtype hsl,
const double &  deltaH
[static]
 

Color VCF::ColorSpace::changeHWB const Color color,
const double &  percentH,
const double &  percentW,
const double &  percentB
[inline, static]
 

ColorSpace::HWBtype VCF::ColorSpace::changeHWB const HWBtype hwb,
const double &  percentH,
const double &  percentW,
const double &  percentB
[inline, static]
 

static void VCF::ColorSpace::changeHWB HWBtype hsl,
const double &  percentH,
const double &  percentW,
const double &  percentB
[static]
 

It is suggested to call this function with colors: 0.0/ 0.0 / 0.71428571428571.

It is suggested to call this function with grays: 0.0/ 0.0 / 0.33333333333333

static HSLtype VCF::ColorSpace::ColorLongToHSL const uint32  color  )  [static]
 

static HSLrangetype VCF::ColorSpace::ColorLongToHSLRange const uint32  color  )  [static]
 

static RGBtype VCF::ColorSpace::ColorLongToRGB const uint32  color  )  [static]
 

uint32 VCF::ColorSpace::ColorToColorLong const Color color  )  [inline, static]
 

ColorSpace::HSLtype VCF::ColorSpace::ColorToHSL const Color rgb  )  [inline, static]
 

ColorSpace::HSVtype VCF::ColorSpace::ColorToHSV const Color rgb  )  [inline, static]
 

ColorSpace::HWBtype VCF::ColorSpace::ColorToHWB const Color rgb  )  [inline, static]
 

ColorSpace::RGBtype VCF::ColorSpace::ColorToRGB const Color color  )  [inline, static]
 

static double VCF::ColorSpace::getChanged const double &  initialVal,
const double &  percent
[static]
 

static int VCF::ColorSpace::getLuminosity const Color color  )  [static]
 

compute the luminosity for an RGB color.

Parameters:
color 
Returns:
int

static uint32 VCF::ColorSpace::HSLRangeToColorLong const HSLrangetype hsl  )  [static]
 

static HSLtype VCF::ColorSpace::HSLRangeToHSL const HSLrangetype hslRange  )  [static]
 

static RGBtype VCF::ColorSpace::HSLRangeToRGB const HSLrangetype hslRange  )  [static]
 

Color VCF::ColorSpace::HSLToColor const HSLtype hsl  )  [inline, static]
 

static uint32 VCF::ColorSpace::HSLToColorLong const HSLtype hsl  )  [static]
 

static HSLrangetype VCF::ColorSpace::HSLToHSLRange const HSLtype hsl  )  [static]
 

static RGBtype VCF::ColorSpace::HSLToRGB const HSLtype hsl  )  [static]
 

Color VCF::ColorSpace::HSVToColor const HSVtype hsl  )  [inline, static]
 

static RGBtype VCF::ColorSpace::HSVToRGB const HSVtype HSV  )  [static]
 

static double VCF::ColorSpace::HueToColorValue const double  Hue,
const double  M1,
const double  M2
[static]
 

helper function

Color VCF::ColorSpace::HWBToColor const HWBtype hsl  )  [inline, static]
 

static RGBtype VCF::ColorSpace::HWBToRGB const HWBtype HWB  )  [static]
 

static RGBtype VCF::ColorSpace::RGBRangeToRGB const RGBrangetype rgbRange  )  [static]
 

Color VCF::ColorSpace::RGBToColor const RGBtype rgb  )  [inline, static]
 

inline implementation for ColorSpace class

static uint32 VCF::ColorSpace::RGBToColorLong const RGBtype rgb  )  [static]
 

static HSLtype VCF::ColorSpace::RGBToHSL const RGBtype rgb  )  [static]
 

static HSLrangetype VCF::ColorSpace::RGBToHSLRange const RGBtype rgb  )  [static]
 

static HSVtype VCF::ColorSpace::RGBToHSV const RGBtype RGB  )  [static]
 

static HWBtype VCF::ColorSpace::RGBToHWB const RGBtype rgb  )  [static]
 

static RGBrangetype VCF::ColorSpace::RGBToRGBRange const RGBtype rgb  )  [static]
 

static void VCF::ColorSpace::setLuminosity Color color,
const int &  luminosity
[static]
 

set the luminosity of a color.

Parameters:
Color& color, the color.
const int& luminosity, the desired luminosity expressed in a [0, ColorSpace::HSLMax] scale.


Member Data Documentation

const double VCF::ColorSpace::HueCriticalMax [static]
 

HueCriticalMax is assigned ( 1.0 - 1.0 / 6.0 ) Hue > HueCriticalMax => rgb.R > 1;.


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information