Humble Framework for SkyOS


Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

HColor Class Reference
[Graphical User InterfaceGraphical User InterfaceGraphical User InterfaceGraphical User Interface]

#include <HColor.h>

Inheritance diagram for HColor:

HObj

Detailed Description

The HColor class provides a wrapper around the COLOR Red/Green/Blue (RGB) triplet. It also defines the 40 or so "named colors" recognized by the W3C web standard:

aliceblue antiquewhite aqua aquamarine
azure beige bisque black
blanchedalmond blue blueviolet brown
burlywood cadetblue chartreuse chocolate
coral cornflower cornsilk crimson
cyan darkblue darkcyan darkgoldenrod
darkgray darkgreen darkkhaki darkmagenta
darkolivegreen darkorange darkorchid darkred
darksalmon darkseagreen darkslateblue darkslategray
darkturquoise darkviolet deeppink deepskyblue
dimgray dodgerblue firebrick floralwhite
forestgreen fuchsia gainsboro ghostwhite
gold goldenrod gray green
greenyellow honeydew hotpink indianred
indigo ivory khaki lavender
lavenderblush lawngreen lemonchiffon lightblue
lightcoral lightcyan lightgoldenrodyellow lightgreen
lightgrey lightpink lightsalmon lightseagreen
lightskyblue lightslategray lightsteelblue lightyellow
lime limegreen linen magenta
maroon mediumaquamarine mediumblue mediumorchid
mediumpurple mediumseagreen mediumslateblue mediumspringgreen
mediumturquoise mediumvioletred midnightblue mintcream
mistyrose moccasin navajowhite navy
oldlace olive olivedrab orange
orangered orchid palegoldenrod palegreen
paleturquoise palevioletred papayawhip peachpuff
peru pink plum powderblue
purple red rosybrown royalblue
saddlebrown salmon sandybrown seagreen
seashell sienna silver skyblue
slateblue slategray snow springgreen
steelblue tan teal thistle
tomato turquoise violet wheat
white whitesmoke yellow yellowgreen

Definition at line 270 of file HColor.h.

Public Types

enum  NamedColor {
  none = MAKE_COLOR(0xFF, 0x00, 0xFF), aliceblue = MAKE_COLOR(0xF0, 0xF8, 0xFF), antiquewhite = MAKE_COLOR(0xFA, 0xEB, 0xD7), aqua = MAKE_COLOR(0x00, 0xFF, 0xFF),
  aquamarine = MAKE_COLOR(0x7F, 0xFF, 0xD4), azure = MAKE_COLOR(0xF0, 0xFF, 0xFF), beige = MAKE_COLOR(0xF5, 0xF5, 0xDC), bisque = MAKE_COLOR(0xFF, 0xE4, 0xC4),
  black = MAKE_COLOR(0x00, 0x00, 0x00), blanchedalmond = MAKE_COLOR(0xFF, 0xEB, 0xCD), blue = MAKE_COLOR(0x00, 0x00, 0xFF), blueviolet = MAKE_COLOR(0x8A, 0x2B, 0xE2),
  brown = MAKE_COLOR(0xA5, 0x2A, 0x2A), burlywood = MAKE_COLOR(0xDE, 0xB8, 0x87), cadetblue = MAKE_COLOR(0x5F, 0x9E, 0xA0), chartreuse = MAKE_COLOR(0x7F, 0xFF, 0x00),
  chocolate = MAKE_COLOR(0xD2, 0x69, 0x1E), coral = MAKE_COLOR(0xFF, 0x7F, 0x50), cornflower = MAKE_COLOR(0x64, 0x95, 0xED), cornsilk = MAKE_COLOR(0xFF, 0xF8, 0xDC),
  crimson = MAKE_COLOR(0xDC, 0x14, 0x3C), cyan = MAKE_COLOR(0x00, 0xFF, 0xFF), darkblue = MAKE_COLOR(0x00, 0x00, 0x8B), darkcyan = MAKE_COLOR(0x00, 0x8B, 0x8B),
  darkgoldenrod = MAKE_COLOR(0xB8, 0x86, 0x0B), darkgray = MAKE_COLOR(0xA9, 0xA9, 0xA9), darkgreen = MAKE_COLOR(0x00, 0x64, 0x00), darkkhaki = MAKE_COLOR(0xBD, 0xB7, 0x6B),
  darkmagenta = MAKE_COLOR(0x8B, 0x00, 0x8B), darkolivegreen = MAKE_COLOR(0x55, 0x6B, 0x2F), darkorange = MAKE_COLOR(0xFF, 0x8C, 0x00), darkorchid = MAKE_COLOR(0x99, 0x32, 0xCC),
  darkred = MAKE_COLOR(0x8B, 0x00, 0x00), darksalmon = MAKE_COLOR(0xE9, 0x96, 0x7A), darkseagreen = MAKE_COLOR(0x8F, 0xBC, 0x8B), darkslateblue = MAKE_COLOR(0x48, 0x3D, 0x8B),
  darkslategray = MAKE_COLOR(0x2F, 0x4F, 0x4F), darkturquoise = MAKE_COLOR(0x00, 0xCE, 0xD1), darkviolet = MAKE_COLOR(0x94, 0x00, 0xD3), deeppink = MAKE_COLOR(0xFF, 0x14, 0x93),
  deepskyblue = MAKE_COLOR(0x00, 0xBF, 0xFF), dimgray = MAKE_COLOR(0x69, 0x69, 0x69), dodgerblue = MAKE_COLOR(0x1E, 0x90, 0xFF), firebrick = MAKE_COLOR(0xB2, 0x22, 0x22),
  floralwhite = MAKE_COLOR(0xFF, 0xFA, 0xF0), forestgreen = MAKE_COLOR(0x22, 0x8B, 0x22), fuchsia = MAKE_COLOR(0xFF, 0x00, 0xFF), gainsboro = MAKE_COLOR(0xDC, 0xDC, 0xDC),
  ghostwhite = MAKE_COLOR(0xF8, 0xF8, 0xFF), gold = MAKE_COLOR(0xFF, 0xD7, 0x00), goldenrod = MAKE_COLOR(0xDA, 0xA5, 0x20), gray = MAKE_COLOR(0x80, 0x80, 0x80),
  green = MAKE_COLOR(0x00, 0x80, 0x00), greenyellow = MAKE_COLOR(0xAD, 0xFF, 0x2F), honeydew = MAKE_COLOR(0xF0, 0xFF, 0xF0), hotpink = MAKE_COLOR(0xFF, 0x69, 0xB4),
  indianred = MAKE_COLOR(0xCD, 0x5C, 0x5C), indigo = MAKE_COLOR(0x4B, 0x00, 0x82), ivory = MAKE_COLOR(0xFF, 0xFF, 0xF0), khaki = MAKE_COLOR(0xF0, 0xE6, 0x8C),
  lavender = MAKE_COLOR(0xE6, 0xE6, 0xFA), lavenderblush = MAKE_COLOR(0xFF, 0xF0, 0xF5), lawngreen = MAKE_COLOR(0x7C, 0xFC, 0x00), lemonchiffon = MAKE_COLOR(0xFF, 0xFA, 0xCD),
  lightblue = MAKE_COLOR(0xAD, 0xD8, 0xE6), lightcoral = MAKE_COLOR(0xF0, 0x80, 0x80), lightcyan = MAKE_COLOR(0xE0, 0xFF, 0xFF), lightgoldenrodyellow = MAKE_COLOR(0xFA, 0xFA, 0xD2),
  lightgreen = MAKE_COLOR(0x90, 0xEE, 0x90), lightgrey = MAKE_COLOR(0xD3, 0xD3, 0xD3), lightpink = MAKE_COLOR(0xFF, 0xB6, 0xC1), lightsalmon = MAKE_COLOR(0xFF, 0xA0, 0x7A),
  lightseagreen = MAKE_COLOR(0x20, 0xB2, 0xAA), lightskyblue = MAKE_COLOR(0x87, 0xCE, 0xFA), lightslategray = MAKE_COLOR(0x77, 0x88, 0x99), lightsteelblue = MAKE_COLOR(0xB0, 0xC4, 0xDE),
  lightyellow = MAKE_COLOR(0xFF, 0xFF, 0xE0), lime = MAKE_COLOR(0x00, 0xFF, 0x00), limegreen = MAKE_COLOR(0x32, 0xCD, 0x32), linen = MAKE_COLOR(0xFA, 0xF0, 0xE6),
  magenta = MAKE_COLOR(0xFF, 0x00, 0xFF), maroon = MAKE_COLOR(0x80, 0x00, 0x00), mediumaquamarine = MAKE_COLOR(0x66, 0xCD, 0xAA), mediumblue = MAKE_COLOR(0x00, 0x00, 0xCD),
  mediumorchid = MAKE_COLOR(0xBA, 0x55, 0xD3), mediumpurple = MAKE_COLOR(0x93, 0x70, 0xDB), mediumseagreen = MAKE_COLOR(0x3C, 0xB3, 0x71), mediumslateblue = MAKE_COLOR(0x7B, 0x68, 0xEE),
  mediumspringgreen = MAKE_COLOR(0x00, 0xFA, 0x9A), mediumturquoise = MAKE_COLOR(0x48, 0xD1, 0xCC), mediumvioletred = MAKE_COLOR(0xC7, 0x15, 0x85), midnightblue = MAKE_COLOR(0x19, 0x19, 0x70),
  mintcream = MAKE_COLOR(0xF5, 0xFF, 0xFA), mistyrose = MAKE_COLOR(0xFF, 0xE4, 0xE1), moccasin = MAKE_COLOR(0xFF, 0xE4, 0xB5), navajowhite = MAKE_COLOR(0xFF, 0xDE, 0xAD),
  navy = MAKE_COLOR(0x00, 0x00, 0x80), oldlace = MAKE_COLOR(0xFD, 0xF5, 0xE6), olive = MAKE_COLOR(0x80, 0x80, 0x00), olivedrab = MAKE_COLOR(0x6B, 0x8E, 0x23),
  orange = MAKE_COLOR(0xFF, 0xA5, 0x00), orangered = MAKE_COLOR(0xFF, 0x45, 0x00), orchid = MAKE_COLOR(0xDA, 0x70, 0xD6), palegoldenrod = MAKE_COLOR(0xEE, 0xE8, 0xAA),
  palegreen = MAKE_COLOR(0x98, 0xFB, 0x98), paleturquoise = MAKE_COLOR(0xAF, 0xEE, 0xEE), palevioletred = MAKE_COLOR(0xDB, 0x70, 0x93), papayawhip = MAKE_COLOR(0xFF, 0xEF, 0xD5),
  peachpuff = MAKE_COLOR(0xFF, 0xDA, 0xB9), peru = MAKE_COLOR(0xCD, 0x85, 0x3F), pink = MAKE_COLOR(0xFF, 0xC0, 0xCB), plum = MAKE_COLOR(0xDD, 0xA0, 0xDD),
  powderblue = MAKE_COLOR(0xB0, 0xE0, 0xE6), purple = MAKE_COLOR(0x80, 0x00, 0x80), red = MAKE_COLOR(0xFF, 0x00, 0x00), rosybrown = MAKE_COLOR(0xBC, 0x8F, 0x8F),
  royalblue = MAKE_COLOR(0x41, 0x69, 0xE1), saddlebrown = MAKE_COLOR(0x8B, 0x45, 0x13), salmon = MAKE_COLOR(0xFA, 0x80, 0x72), sandybrown = MAKE_COLOR(0xF4, 0xA4, 0x60),
  seagreen = MAKE_COLOR(0x2E, 0x8B, 0x57), seashell = MAKE_COLOR(0xFF, 0xF5, 0xEE), sienna = MAKE_COLOR(0xA0, 0x52, 0x2D), silver = MAKE_COLOR(0xC0, 0xC0, 0xC0),
  skyblue = MAKE_COLOR(0x87, 0xCE, 0xEB), slateblue = MAKE_COLOR(0x6A, 0x5A, 0xCD), slategray = MAKE_COLOR(0x70, 0x80, 0x90), snow = MAKE_COLOR(0xFF, 0xFA, 0xFA),
  springgreen = MAKE_COLOR(0x00, 0xFF, 0x7F), steelblue = MAKE_COLOR(0x46, 0x82, 0xB4), tan = MAKE_COLOR(0xD2, 0xB4, 0x8C), teal = MAKE_COLOR(0x00, 0x80, 0x80),
  thistle = MAKE_COLOR(0xD8, 0xBF, 0xD8), tomato = MAKE_COLOR(0xFF, 0x63, 0x47), turquoise = MAKE_COLOR(0x40, 0xE0, 0xD0), violet = MAKE_COLOR(0xEE, 0x82, 0xEE),
  wheat = MAKE_COLOR(0xF5, 0xDE, 0xB3), white = MAKE_COLOR(0xFF, 0xFF, 0xFF), whitesmoke = MAKE_COLOR(0xF5, 0xF5, 0xF5), yellow = MAKE_COLOR(0xFF, 0xFF, 0x00),
  yellowgreen = MAKE_COLOR(0x9A, 0xCD, 0x32)
}

Public Member Functions

 HColor (const COLOR &color)
 HColor (int32 nR, int32 nG, int32 nB)
virtual StringPtr ToString (void) const
 Returns the object's value as a human-readble string.
COLOR Get (void) const
 Returns the color as an RGB triplet.
void GetHLS (float &fHue, float &fLum, float &fSat) const
 Returns the color as a HLS triplet.
uint8 GetRed (void) const
 Returns the RED component of an RGB triplet.
uint8 GetGreen (void) const
 Returns the GREEN component of an RGB triplet.
uint8 GetBlue (void) const
 Returns the BLUE component of an RGB triplet.
void Set (COLOR clr)
 Sets the color.
void SetRed (int32 nR)
 Sets only the RED component of an RGB triplet.
void SetGreen (int32 nG)
 Sets only the GREEN component of an RGB triplet.
void SetBlue (int32 nB)
 Sets only the BLUE component of an RGB triplet.
void SetHLS (float fHue, float fLum, float fSat)
 Sets the color based on a HLS triplet.
void SetRGB (int32 nR, int32 nG, int32 nB)
 Sets the color to an RGB triplet.
 operator COLOR () const
HColoroperator= (const COLOR &color)
bool operator== (const COLOR &color)
bool operator== (const HColor &rhs)
bool operator!= (const COLOR &color)
bool operator!= (const HColor &rhs)

Static Public Member Functions

static COLOR Tint (COLOR color, float fAmount)
 Lightens the given color by a percentage.
static void ConvertToHLS (const COLOR &color, float &fHue, float &fLum, float &fSat) throw ()
 Converts an RGB color to it's HLS triplet equivalent.
static COLOR ConvertToRGB (float fHue, float fLum, float fSat)
 Converts an HLS triplet to an RGB triplet.
static COLOR GetNamedColor (HColor::NamedColor namedColor)
 Return a named color as an RGB triplet.

Static Protected Member Functions

static uint8 boundRGB (int32 nVal)
 Limit a variable to the range of values 0..UINT8_MAX.
static uint8 toRGB (float rm1, float rm2, float rh)
 Converts an HSL value to it's RGB equivalent.

Protected Attributes

COLOR m_color
 Store the actual color value.


Member Function Documentation

static uint8 HColor::boundRGB int32  nVal  )  [static, protected]
 

This method ensures that an RGB component is within the range of values 0 to UINT8_MAX (0..255) returning the minimum or maximum as appropriate.

Returns:
Bounded value
Parameters:
nVal Value to be bounded

Definition at line 452 of file HColor.h.

static uint8 HColor::toRGB float  rm1,
float  rm2,
float  rh
[static, protected]
 

Returns:
RGB octet
Parameters:
rm1 
rm2 
rh 

Definition at line 463 of file HColor.h.

static COLOR HColor::Tint COLOR  color,
float  fAmount
[static]
 

Returns:
Updated color value
Parameters:
color Color to adjust
fAmount Amount (< 1.0 to darken or > 1.0 to lighten)

Definition at line 489 of file HColor.h.

static void HColor::ConvertToHLS const COLOR &  color,
float &  fHue,
float &  fLum,
float &  fSat
throw () [static]
 

See also:
ConvertToRGB
Converts the RGB triplet to a Hue/Luminance/Saturation triplet.

The HSL <-> RGB conversion is based on source code published with the article CColor class by Christian Rodemeyer.

Parameters:
color RGB color triplet to convert
[out] fHue Hue value
[out] fLum Luminance value
[out] fSat Saturation value

Definition at line 541 of file HColor.h.

static COLOR HColor::ConvertToRGB float  fHue,
float  fLum,
float  fSat
[static]
 

See also:
ConvertToHLS
Converts a Hue/Luminance/Saturation triplet to it's RGB equivalent

The HSL <-> RGB conversion is based on source code published with the article CColor class by Christian Rodemeyer.

Returns:
RGB color triplet
Parameters:
fHue Hue value
fLum Luminance value
fSat Saturation value

Definition at line 598 of file HColor.h.

virtual StringPtr HColor::ToString void   )  const [virtual]
 

Returns:
Ptr to string

Definition at line 627 of file HColor.h.

COLOR HColor::Get void   )  const
 

Returns:
COLOR value

Definition at line 642 of file HColor.h.

void HColor::GetHLS float &  fHue,
float &  fLum,
float &  fSat
const
 

Converts the RGB triplet to a Hue/Luminance/Saturation triplet

Parameters:
[out] fHue Hue value
[out] fLum Luminance value
[out] fSat Saturation value

Definition at line 653 of file HColor.h.

static COLOR HColor::GetNamedColor HColor::NamedColor  namedColor  )  [static]
 

This function is not really a function, as the enumerated constant is already set to the RGB color triplet.

Returns:
RGB color triplet (or black if not recognized)
Parameters:
namedColor Color constant

Definition at line 664 of file HColor.h.

uint8 HColor::GetRed void   )  const
 

Returns:
RED value

Definition at line 668 of file HColor.h.

uint8 HColor::GetGreen void   )  const
 

Returns:
GREEN value

Definition at line 672 of file HColor.h.

uint8 HColor::GetBlue void   )  const
 

Returns:
BLUE value

Definition at line 676 of file HColor.h.

void HColor::Set COLOR  clr  ) 
 

Parameters:
clr New color

Definition at line 680 of file HColor.h.

void HColor::SetRed int32  nR  ) 
 

Parameters:
nR RED value

Definition at line 684 of file HColor.h.

void HColor::SetGreen int32  nG  ) 
 

Parameters:
nG GREEN value

Definition at line 688 of file HColor.h.

void HColor::SetBlue int32  nB  ) 
 

Parameters:
nB BLUE value

Definition at line 692 of file HColor.h.

void HColor::SetHLS float  fHue,
float  fLum,
float  fSat
 

Converts the Hue/Luminance/Saturation triplet to RGB

Parameters:
fHue Hue value (0.0 <= ? <= 1.0)
fLum Luminance value (0.0 <= ? <= 1.0)
fSat Saturation value (0.0 <= ? <= 1.0)

Definition at line 703 of file HColor.h.

void HColor::SetRGB int32  nR,
int32  nG,
int32  nB
 

Sets the value to an RGB triplet (similar to the MAKE_COLOR() macro). If the value is less than zero, it is set to zero; if the value exceeds UINT8_MAX (255) it is set to UINT8_MAX.

Parameters:
nR The RED component (0..UINT8_MAX)
nG The GREEN component (0..UINT8_MAX)
nB The BLUE component (0..UINT8_MAX)

Definition at line 716 of file HColor.h.


The documentation for this class was generated from the following file:
 

2006.01.09-16:37