MinGfx Toolkit
1.0
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
|
Represents a 4-component (R,G,B,A) color, stored internally in a float array to be compatable with OpenGL.
Example usage:
#include <color.h>
Public Member Functions | |
Color () | |
Defaults to black. More... | |
Color (float red, float green, float blue, float alpha=1.0) | |
Constructs a color. Alpha defaults to 1.0 (completely opaque) More... | |
Color (float *p) | |
Constructs a point given a pointer to float array. More... | |
Color (const std::vector< float > &vals) | |
Constructs a point given a 3 or 4-element vector of floats. More... | |
Color (const Color &p) | |
Copy constructor. More... | |
virtual | ~Color () |
Color destructor. More... | |
bool | operator== (const Color &p) const |
Check for equality. More... | |
bool | operator!= (const Color &p) const |
Check for inequality. More... | |
Color & | operator= (const Color &p) |
Assignment operator. More... | |
float | operator[] (const int i) const |
Accesses the ith component of the color, stored in RGBA order. More... | |
float & | operator[] (const int i) |
Accesses the ith coordinate of the color, stored in RGBA order. More... | |
const float * | value_ptr () const |
Returns a const pointer to the raw data array. More... | |
std::vector< float > | ToVector () const |
Color | Lerp (const Color &b, float alpha) const |
Linear interpolation between this color and another. Alpha=0.0 returns this color, and alpha=1.0 returns the other color, other values blend between the two via a linear interpolation on each color channel. More... | |
Static Public Member Functions | |
static Color | Lerp (const Color &a, const Color &b, float alpha) |
Linear interpolation between two colors. Alpha=0.0 returns 'a' and alpha=1.0 returns 'b', other values blend between the two via a linear interpolation on each color channel. More... | |
mingfx::Color::Color | ( | ) |
Defaults to black.
mingfx::Color::Color | ( | float | red, |
float | green, | ||
float | blue, | ||
float | alpha = 1.0 |
||
) |
Constructs a color. Alpha defaults to 1.0 (completely opaque)
mingfx::Color::Color | ( | float * | p | ) |
Constructs a point given a pointer to float array.
mingfx::Color::Color | ( | const std::vector< float > & | vals | ) |
Constructs a point given a 3 or 4-element vector of floats.
mingfx::Color::Color | ( | const Color & | p | ) |
Copy constructor.
|
virtual |
Color destructor.
Linear interpolation between two colors. Alpha=0.0 returns 'a' and alpha=1.0 returns 'b', other values blend between the two via a linear interpolation on each color channel.
Linear interpolation between this color and another. Alpha=0.0 returns this color, and alpha=1.0 returns the other color, other values blend between the two via a linear interpolation on each color channel.
bool mingfx::Color::operator!= | ( | const Color & | p | ) | const |
Check for inequality.
bool mingfx::Color::operator== | ( | const Color & | p | ) | const |
Check for equality.
float& mingfx::Color::operator[] | ( | const int | i | ) |
Accesses the ith coordinate of the color, stored in RGBA order.
float mingfx::Color::operator[] | ( | const int | i | ) | const |
Accesses the ith component of the color, stored in RGBA order.
std::vector<float> mingfx::Color::ToVector | ( | ) | const |
const float* mingfx::Color::value_ptr | ( | ) | const |
Returns a const pointer to the raw data array.