struct ffw::Color
Class List > ffw :: Color
Class that holds floating point color, OpenGL friendly. More...
Public Attributes
Type | Name |
---|---|
float | r |
float | g |
float | b |
float | a |
Public Functions
Type | Name |
---|---|
Color () Default constructor, sets color to black with 0% alpha. | |
Color (float red, float green, float blue, float alpha) Construcor, sets the color based on the parameters. | |
Color (float val, float alpha) Constructor, sets the color to grayscale with alpha. | |
Color (const Color & vec) Copy Constructor. | |
Color (const std::initializer_list< float > & list) Construcor, sets the color from braced list of 4 floating point values. | |
void | set (float red, float green, float blue, float alpha) Sets the color. |
void | set (float val, float alpha) Sets the color. |
void | set (const Color & vec) Sets the color from another color class. |
void | set (const std::initializer_list< float > & list) Sets the color from a braced list of 4 floating point values. |
ffw::Color | operator- () const Performs unary minus operation on all r,g,b,a channels. |
ffw::Color & | operator= (const Color & vec) Copies values from different color instance. |
ffw::Color | operator+ (const Color & vec) const Adds together two colors, returning a copy. |
ffw::Color & | operator+= (const Color & vec) Adds together two colors. |
ffw::Color | operator- (const Color & vec) const Substracts together two colors, returning a copy. |
ffw::Color & | operator-= (const Color & vec) Substracts together two colors. |
ffw::Color | operator/ (const Color & vec) const |
ffw::Color & | operator/= (const Color & vec) |
ffw::Color | operator* (const Color & vec) const |
ffw::Color & | operator*= (const Color & vec) |
ffw::Color & | operator= (const float & val) Assigns same value to all RGBA components. |
ffw::Color | operator+ (const float & val) const Adds value to all RGBA components, returning a copy. |
ffw::Color & | operator+= (const float & val) Adds value to all RGBA components. |
ffw::Color | operator- (const float & val) const Substracts from all RGBA components, returning a copy. |
ffw::Color & | operator-= (const float & val) Substracts from all RGBA components. |
ffw::Color | operator/ (const float & val) const |
ffw::Color & | operator/= (const float & val) |
ffw::Color | operator* (const float & val) const |
ffw::Color & | operator*= (const float & val) |
bool | operator!= (const Color & vec) const Checks if this instance is not equal to other one, using epsilon. |
bool | operator== (const Color & vec) const Checks if this instance is equal to other one, using epsilon. |
ffw::Color & | clamp () Clamps all RGBA components so that all values are between 0.0 and 1.0. |
ffw::Color & | normalize () Normalises a color. |
ffw::Color & | scale (const float val) Scales all RGBA components with single value. |
double | length () const Returns the length of a vector (color is treated as a vector) |
float | lengthf () const Returns the length of a vector (color is treated as a vector) |
float | lengthSqrd () const Returns the squared length of a vector (color is treated as a vector) |
Color | inverted () const Returns the inverted R, G, and B components. |
Detailed Description
You can use this class to represent any RGBA color and pass it to your OpenGL function. This class uses 4 floats to represent color combinations. For example, 100% red color is when r is set to 1.0f and all other (g, b, a) is set to 0.0. You can also use ffw::rgba function to construct this class with less typing
See also: ffw::rgb, ffw::rgba,
Public Attributes Documentation
variable r
float ffw::Color::r;
variable g
float ffw::Color::g;
variable b
float ffw::Color::b;
variable a
float ffw::Color::a;
Public Functions Documentation
function Color (1/5)
ffw::Color::Color ()
Default constructor, sets color to black with 0% alpha.
function Color (2/5)
ffw::Color::Color (
float red,
float green,
float blue,
float alpha
)
Construcor, sets the color based on the parameters.
function Color (3/5)
ffw::Color::Color (
float val,
float alpha
)
Constructor, sets the color to grayscale with alpha.
function Color (4/5)
ffw::Color::Color (
const Color & vec
)
Copy Constructor.
function Color (5/5)
ffw::Color::Color (
const std::initializer_list< float > & list
)
Construcor, sets the color from braced list of 4 floating point values.
function set (1/4)
void ffw::Color::set (
float red,
float green,
float blue,
float alpha
)
Sets the color.
function set (2/4)
void ffw::Color::set (
float val,
float alpha
)
Sets the color.
function set (3/4)
void ffw::Color::set (
const Color & vec
)
Sets the color from another color class.
function set (4/4)
void ffw::Color::set (
const std::initializer_list< float > & list
)
Sets the color from a braced list of 4 floating point values.
function operator- (1/3)
ffw::Color ffw::Color::operator- () const
Performs unary minus operation on all r,g,b,a channels.
function operator= (1/2)
ffw::Color & ffw::Color::operator= (
const Color & vec
)
Copies values from different color instance.
function operator+ (1/2)
ffw::Color ffw::Color::operator+ (
const Color & vec
) const
Adds together two colors, returning a copy.
function operator+= (1/2)
ffw::Color & ffw::Color::operator+= (
const Color & vec
)
Adds together two colors.
function operator- (2/3)
ffw::Color ffw::Color::operator- (
const Color & vec
) const
Substracts together two colors, returning a copy.
function operator-= (1/2)
ffw::Color & ffw::Color::operator-= (
const Color & vec
)
Substracts together two colors.
function operator/ (1/2)
ffw::Color ffw::Color::operator/ (
const Color & vec
) const
function operator/= (1/2)
ffw::Color & ffw::Color::operator/= (
const Color & vec
)
function operator* (1/2)
ffw::Color ffw::Color::operator* (
const Color & vec
) const
function operator*= (1/2)
ffw::Color & ffw::Color::operator*= (
const Color & vec
)
function operator= (2/2)
ffw::Color & ffw::Color::operator= (
const float & val
)
Assigns same value to all RGBA components.
function operator+ (2/2)
ffw::Color ffw::Color::operator+ (
const float & val
) const
Adds value to all RGBA components, returning a copy.
function operator+= (2/2)
ffw::Color & ffw::Color::operator+= (
const float & val
)
Adds value to all RGBA components.
function operator- (3/3)
ffw::Color ffw::Color::operator- (
const float & val
) const
Substracts from all RGBA components, returning a copy.
function operator-= (2/2)
ffw::Color & ffw::Color::operator-= (
const float & val
)
Substracts from all RGBA components.
function operator/ (2/2)
ffw::Color ffw::Color::operator/ (
const float & val
) const
function operator/= (2/2)
ffw::Color & ffw::Color::operator/= (
const float & val
)
function operator* (2/2)
ffw::Color ffw::Color::operator* (
const float & val
) const
function operator*= (2/2)
ffw::Color & ffw::Color::operator*= (
const float & val
)
function operator!=
bool ffw::Color::operator!= (
const Color & vec
) const
Checks if this instance is not equal to other one, using epsilon.
function operator==
bool ffw::Color::operator== (
const Color & vec
) const
Checks if this instance is equal to other one, using epsilon.
function clamp
ffw::Color & ffw::Color::clamp ()
Clamps all RGBA components so that all values are between 0.0 and 1.0.
Note:
Does not perform a normalization!
function normalize
ffw::Color & ffw::Color::normalize ()
Normalises a color.
Note:
Color is treated as a 3D vector but alpha is ignored and clamped instead.
function scale
ffw::Color & ffw::Color::scale (
const float val
)
Scales all RGBA components with single value.
function length
double ffw::Color::length () const
Returns the length of a vector (color is treated as a vector)
function lengthf
float ffw::Color::lengthf () const
Returns the length of a vector (color is treated as a vector)
function lengthSqrd
float ffw::Color::lengthSqrd () const
Returns the squared length of a vector (color is treated as a vector)
function inverted
Color ffw::Color::inverted () const
Returns the inverted R, G, and B components.
The documentation for this class was generated from the following file: include/ffw/graphics/color.h