Polycode
Polycode::Color Class Reference

Stores and manipulates color information. More...

List of all members.

Public Member Functions

 Color ()
 Default constructor.
 Color (int r, int g, int b, int a)
 Create from 0-255 integer data.
 Color (Number r, Number g, Number b, Number a)
 Create from 0-1 floating point data.
 Color (const Color *color)
 Create from another color.
 Color (unsigned int hex)
 Create from integer color.
Color operator* (const Color &v2) const
 Multiplies the color with another color.
Color operator+ (const Color &v2) const
 Adds the color to another color.
void setColorHex (unsigned int hex)
 Sets the color using an integer color value.
void setColorHexRGB (unsigned int hex)
 Sets the color using a 24-bit RGB integer color value.
void setColorHSV (Number h, Number s, Number v)
 Sets the color using HSV values.
void setColorRGBA (int r, int g, int b, int a)
 Sets the color using 0-255 RGBA integers.
void setColorRGB (int r, int g, int b)
 Sets the color using 0-255 RGB integers.
void setColor (Number r, Number g, Number b, Number a)
 Set from 0-1 floating point data.
void setColor (const Color *color)
 Set from another color.
void Random ()
 Sets the color to a random color.
Number getBrightness () const
 Retuns the brightness of the color.
Number getHue () const
 Returns the hue of the color's HSV component.
Number getSaturation () const
 Returns the saturation of the color's HSV component.
Number getValue () const
 Returns the value of the color's HSV component.
unsigned int getUint () const
 Returns the color as a 32-bit usigned integer.

Public Attributes

Number r
 Red value.
Number g
 Green value.
Number b
 Blue value.
Number a
 Alpha value.

Detailed Description

Stores and manipulates color information.

Color is always RGBA in Polycode.


Constructor & Destructor Documentation

Color::Color ( int  r,
int  g,
int  b,
int  a 
)

Create from 0-255 integer data.

Parameters:
rRed value 0-255.
gGreen value 0-255.
bBlue value 0-255.
aAlpha value 0-255.
Color::Color ( Number  r,
Number  g,
Number  b,
Number  a 
)

Create from 0-1 floating point data.

Parameters:
rRed value 0-1.
gGreen value 0-1
bBlue value 0-1
aAlpha value 0-1
Color::Color ( const Color color)

Create from another color.

Parameters:
colorThe color to create from.
Color::Color ( unsigned int  hex)

Create from integer color.

Parameters:
hexInteger color value.

Member Function Documentation

Number Color::getBrightness ( ) const

Retuns the brightness of the color.

Returns:
Brightness.
Number Color::getHue ( ) const

Returns the hue of the color's HSV component.

Returns:
HSV Hue.
Number Color::getSaturation ( ) const

Returns the saturation of the color's HSV component.

Returns:
HSV Saturation
unsigned int Color::getUint ( ) const

Returns the color as a 32-bit usigned integer.

Returns:
Color as a single 32-bit unsigned integer.
Number Color::getValue ( ) const

Returns the value of the color's HSV component.

Returns:
HSV Value
void Color::Random ( )

Sets the color to a random color.

This does not affect alpha.

void Color::setColor ( Number  r,
Number  g,
Number  b,
Number  a 
)

Set from 0-1 floating point data.

Parameters:
rRed value 0-1.
gGreen value 0-1
bBlue value 0-1
aAlpha value 0-1
void Color::setColor ( const Color color)

Set from another color.

Parameters:
colorThe color to set from.
void Color::setColorHex ( unsigned int  hex)

Sets the color using an integer color value.

Parameters:
hex32-bit integer with color values.
void Color::setColorHexRGB ( unsigned int  hex)

Sets the color using a 24-bit RGB integer color value.

Parameters:
hex24-bit integer with RGB color values.
void Color::setColorHSV ( Number  h,
Number  s,
Number  v 
)

Sets the color using HSV values.

Parameters:
hHue.
sSaturation.
vValue.
void Color::setColorRGB ( int  r,
int  g,
int  b 
)

Sets the color using 0-255 RGB integers.

Parameters:
rRed value 0-255.
gGreen value 0-255.
bBlue value 0-255.
void Color::setColorRGBA ( int  r,
int  g,
int  b,
int  a 
)

Sets the color using 0-255 RGBA integers.

Parameters:
rRed value 0-255.
gGreen value 0-255.
bBlue value 0-255.
aAlpha value 0-255.