Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

ap_color Class Reference

A class to hold a color. More...

#include <color.h>

List of all members.

Public Member Functions

void set (int r, int g, int b, int a)
 Function to set the values for a color.

 ap_color (double r, double g, double b, double a=1.0)
 Constructor to create a color using floating point values.

 ap_color (int r, int g, int b, int a=255)
 Constructor to create a color using byte values.

 ap_color ()
 Default constructor.


Public Attributes

byte r
 red

byte g
 green

byte b
 blue

byte a
 alpha


Detailed Description

A class to hold a color.

Author:
Ray Seyfarth
The colors stored in the animp animation files are stored as 4 byte values per color. The objects stored in the files use a single byte index to refer to the colors stored in the same file.

Each color is composed of red, green and blue color values along with an alpha value. These values all range from 0 to 255. A color with RGB values <255,0,0> is a bright red. The combination <255,255,0> is red and green which yields yellow. These values are scaled to fit the range 0.0 to 1.0 when used to define colors in OpenGL.

The alpha component is used in OpenGL to control blending of colors. An object with alpha value 255 (1.0 for OpenGL) is opaque and will replace the pixels of previously drawn objects which are behind an object. Smaller values for alpha allow differing amounts of color from more distant objects to blend with the color of an object being drawn.

OpenGL allows the programmer to choose between several blending functions. Animp uses the most obvious blending function with is named in OpenGL as GL_SRC_ALPHA for the source object and GL_ONE_MINUS_SRC_ALPHA for the existing pixels already rendered. This means that if you are currently drawing an object with alpha value 0.3, 30% of the color comes from the object itself and 70% from the objects behind it. Note that this only works if the more distant objects are already rendered. This is the reason why animp sorts the objects it draws.

Todo:
Allow reading and writing color table files.


Constructor & Destructor Documentation

ap_color::ap_color double  r,
double  g,
double  b,
double  a = 1.0
 

Constructor to create a color using floating point values.

This is a logical choice to use since so much OpenGL code and documentation use floating point color values. Note that the default value for alpha is 1.0 which means that colors are opaque unless you specify a different alpha value.

ap_color::ap_color int  r,
int  g,
int  b,
int  a = 255
 

Constructor to create a color using byte values.

Note that the default value for alpha is 255 which means that colors are opaque unless you specify a different alpha value.

ap_color::ap_color  ) 
 

Default constructor.

The default color is an opaque black.


Member Function Documentation

void ap_color::set int  r,
int  g,
int  b,
int  a
 

Function to set the values for a color.

This is used internally by the various constructors to avoid code duplication.


Member Data Documentation

byte ap_color::r
 

red

byte ap_color::g
 

green

byte ap_color::b
 

blue

byte ap_color::a
 

alpha


The documentation for this class was generated from the following files:
Generated on Thu Nov 27 08:17:11 2003 for Animp - Animated Particles by doxygen 1.3.2