ClanSoft logo
ClanSoft logo
Entire Class Index Main Class Index Cross Index Global Index

Class CL_Color

The Color class
Contained in: global
Derived from: none
Derived by: none
Group: Display (Display 2D)

#include <ClanLib/display.h>


public function member index:

Attributes:

static unsigned int get_red_mask(EPixelFormat pixelformat);
static unsigned int get_green_mask(EPixelFormat pixelformat);
static unsigned int get_blue_mask(EPixelFormat pixelformat);
static unsigned int get_alpha_mask(EPixelFormat pixelformat);
static unsigned int get_color(EPixelFormat fmt, int r, int g, int b, int a=255);
static unsigned int get_color(EPixelFormat fmt, float r, float g, float b, float a=1.0);
static unsigned int get_color(unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask, int r, int g, int b, int a=255);
static unsigned int get_color(unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask, float r, float g, float b, float a=1.0);
static unsigned int get_color(CL_Target* target, int r, int g, int b, int a=255);
static unsigned int get_color(CL_Target* target, float r, float g, float b, float a=1.0);
static float get_color(unsigned int cmask, int color);
 

Description:

This class provides methods that deal with colors, including the ability to find color-component bit masks for particular pixel formats. Also you can use this class to get colors, in any of the different pixel formats, from the color components (Red, Blue, Green and Alpha).
Often you can specify color components as either integers or floating points (the component value divided by it's maximum possible value.)


Function Member Descriptions:

CL_Color::get_alpha_mask - Returns the bit mask for alpha using the given pixel format.
static unsigned int get_alpha_mask(EPixelFormat pixelformat);


CL_Color::get_blue_mask - Returns the bit mask for blue using the given pixel format.
static unsigned int get_blue_mask(EPixelFormat pixelformat);


CL_Color::get_color - Returns the color value for the specified red, blue and green floating point components in the same pixel format as the target.
static unsigned int get_color(CL_Target* target, float r, float g, float b, float a=1.0);
target - pointer to the target
r - the red value as a floating point
g - the green value as a floating point
b - the blue value as a floating point



CL_Color::get_color - Takes a color, extracts the color component (red, green, blue or alpha) specified by cmask, and returns it as a floating point. (The floating point value is the amount of the color component divided by that color component's maximum value.)
For example:
If the red component has a maximum value of 255, and the red component of your color was 200, the floating point returned would be 200/255 or 0.7843
static float get_color(unsigned int cmask, int color);
cmask - the bit mask for the color component you want
color - the color to extract the component from
Returns - the R, G, B or A value as a floating point



CL_Color::get_color - Converts separate red, blue, green and alpha integer values into a color value
static unsigned int get_color(EPixelFormat fmt, int r, int g, int b, int a=255);
fmt - the pixel format to use
r - the red value as an integer
g - the green value as an integer
b - the blue value as an integer
a - the alpha value as an integer(defaults to opaque)
Returns - the color value in the requested pixel format



CL_Color::get_color - Converts separate red, blue, green and alpha floating point values into a single color value
static unsigned int get_color(EPixelFormat fmt, float r, float g, float b, float a=1.0);
fmt - the pixel format to use
r - the red value as a floating point number
g - the green value as a floating point number
b - the blue value as a floating point number
a - the alpha value as a floating point number (defaults to opaque)
Returns - the color value in the requested pixel format



CL_Color::get_color - Returns the color value in a format you specify by giving the red, green, blue and alpha masks, along with the corresponding red, blue, green and alpha values.
static unsigned int get_color(unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask, int r, int g, int b, int a=255);
rmask - the bit mask for red
gmask - the bit mask for green
bmask - the bit mask for blue
amask - the bit mask for the alpha
r - the red value as an integer
g - the green value as an integer
b - the blue value as an integer
a - the alpha value as an integer (default is opaque)
Returns - the color value in the format you specify



CL_Color::get_color - Returns the color value in a format you specify by giving the red, green, blue and alpha masks, along with the corresponding red, blue, green and alpha values.
static unsigned int get_color(unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask, float r, float g, float b, float a=1.0);
rmask - the bit mask for red
gmask - the bit mask for green
bmask - the bit mask for blue
amask - the bit mask for the alpha
r - the red value as a floating point
g - the green value as a floating point
b - the blue value as a flaoting point
a - the alpha value as a floating point (default is opaque)
Returns - the color value in the format you specify



CL_Color::get_color - Returns the color value for the specified red, blue and green integer components, in the same pixel format as the target.static unsigned int get_color(CL_Target* target, int r, int g, int b, int a=255);
target - a pointer to a target </p>
r - the red value as an integer
g - the green value as an integer
b - the blue value as an integer
a - the alpha value (default is opaque)



CL_Color::get_green_mask - Returns the bit mask for green using the given pixel format.
static unsigned int get_green_mask(EPixelFormat pixelformat);


CL_Color::get_red_mask - Returns the bit mask for red using the given pixel format.
static unsigned int get_red_mask(EPixelFormat pixelformat);