NGL  6.5
The NCCA Graphics Library
ngl::Colour Class Reference

simple class to hold colour information and set the basic opengl colour state. also has overloaded methods to do basic math on colour values. More...

#include <Colour.h>

+ Collaboration diagram for ngl::Colour:

Public Member Functions

 Colour (Real _r=0.0, Real _g=0.0, Real _b=0.0, Real _a=1.0) noexcept
 constructor passing in r g b components More...
 
 Colour (const Colour &_c) noexcept
 copy constructor passing in a Colour More...
 
void set (Real _r, Real _g, Real _b, Real _a=1.0f) noexcept
 set method to change the current values of the colour as well as the transparency More...
 
void set (const Colour &_c) noexcept
 set method to set from another Colour More...
 
Colour operator+ (const Colour &_c) const noexcept
 
  • operator to add two colours
More...
 
Colour operator- (const Colour &_c) const noexcept
 
  • operator to subtract colours
More...
 
const Colouroperator+= (const Colour &_c) noexcept
 
  • operator to add rhs to current colour
More...
 
Colour operator* (const Colour &_c) const noexcept
 
  • operator to multiply colours
More...
 
Colour operator* (const Real _c) const noexcept
 
  • operator to multiply by a scalar
More...
 
const Colouroperator*= (const Colour &_c) noexcept
 
  • operator to multiply = by a colour
More...
 
const Colouroperator*= (Real _c) noexcept
 
  • operator to multiply by a scalar
More...
 
void add (const Colour &_src, const Colour &_refl) noexcept
 
RealopenGL () noexcept
 accesor method to return a pointer to the colour array More...
 
void clamp (Real _min, Real _max) noexcept
 clamp the colour to the given range from Eduard Zell MSc 2010 the input values >0 < 1.0 and _min <= _max More...
 

Public Attributes

Real m_r
 red component of the colour tuple More...
 
Real m_g
 green component of the colour tuple More...
 
Real m_b
 blue component of the colour tuple More...
 
Real m_a
 alpha the transparent element More...
 
Real m_openGL [4]
 The data as an array of 4 floats useful for passing to OpenGL fv data types this is mapped as a union to the following
m_r == m_openGL[0]
m_g == m_openGL[1]
m_b == m_openGL[2]
m_a == m_openGL[3]
. More...
 

Friends

class Material
 

Detailed Description

simple class to hold colour information and set the basic opengl colour state. also has overloaded methods to do basic math on colour values.

Author
Jonathan Macey
Version
5.0
Date
20/10/10 added python binding see Colour.inc.h
Last Revision 29/09/09 Updated to NCCA coding standard
Todo:
add code to use other colour spaces, could be done like Renderman with ctor "HSV" etc

Definition at line 40 of file Colour.h.

Constructor & Destructor Documentation

ngl::Colour::Colour ( Real  _r = 0.0,
Real  _g = 0.0,
Real  _b = 0.0,
Real  _a = 1.0 
)
inlinenoexcept

constructor passing in r g b components

Parameters
[in]_rred component
[in]_ggreen component
[in]_bblue component
[in]_athe alpha component

Definition at line 50 of file Colour.h.

ngl::Colour::Colour ( const Colour _c)
inlinenoexcept

copy constructor passing in a Colour

Parameters
[in]_cthe colour to use

Definition at line 57 of file Colour.h.

Member Function Documentation

void ngl::Colour::add ( const Colour _src,
const Colour _refl 
)
noexcept

add the product of source color and reflection coefficient

Parameters
[in]_srcthe source colour
[in]_reflthe reflected colour

Definition at line 27 of file Colour.cpp.

void ngl::Colour::clamp ( Real  _min,
Real  _max 
)
noexcept

clamp the colour to the given range from Eduard Zell MSc 2010 the input values >0 < 1.0 and _min <= _max

Parameters
_min[in]the minimum colour clamp value
_max[in]the maximum colour clamp value

Definition at line 104 of file Colour.cpp.

Real* ngl::Colour::openGL ( )
inlinenoexcept

accesor method to return a pointer to the colour array

Returns
m_openGL[0] the first element of the array

Definition at line 133 of file Colour.h.

Colour ngl::Colour::operator* ( const Colour _c) const
noexcept

  • operator to multiply colours

Parameters
[in]_cthe Colour to mult
Returns
this*_c

Definition at line 63 of file Colour.cpp.

Colour ngl::Colour::operator* ( const Real  _c) const
noexcept

  • operator to multiply by a scalar

Parameters
[in]_cthe scalar to multiply colour by
Returns
this*_c

Definition at line 73 of file Colour.cpp.

const Colour & ngl::Colour::operator*= ( const Colour _c)
noexcept

  • operator to multiply = by a colour

Parameters
[in]_cthe scalar to multiply colour by
Returns
this*=_c

Definition at line 83 of file Colour.cpp.

References m_r.

const Colour & ngl::Colour::operator*= ( Real  _c)
noexcept

  • operator to multiply by a scalar

Parameters
[in]_cthe scalar to multiply colour by
Returns
this*_c

Definition at line 93 of file Colour.cpp.

Colour ngl::Colour::operator+ ( const Colour _c) const
noexcept

  • operator to add two colours

Parameters
[in]_cthe Colour to add
Returns
this+_c

Definition at line 36 of file Colour.cpp.

const Colour & ngl::Colour::operator+= ( const Colour _c)
noexcept

  • operator to add rhs to current colour

Parameters
[in]_cthe Colour to add
Returns
this+_c

Definition at line 54 of file Colour.cpp.

References m_r.

Colour ngl::Colour::operator- ( const Colour _c) const
noexcept

  • operator to subtract colours

Parameters
[in]_cthe Colour to add
Returns
this-_c

Definition at line 45 of file Colour.cpp.

void ngl::Colour::set ( Real  _r,
Real  _g,
Real  _b,
Real  _a = 1.0f 
)
inlinenoexcept

set method to change the current values of the colour as well as the transparency

Parameters
[in]_rred component to be set
[in]_ggreen component to be set
[in]_bblue component to be set
[in]_aalpha transparency value

Definition at line 68 of file Colour.h.

void ngl::Colour::set ( const Colour _c)
inlinenoexcept

set method to set from another Colour

Parameters
[in]_cthe colour

Definition at line 76 of file Colour.h.

References ngl::operator*().

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class Material
friend
Note
I've made this public as some compilers automatically make the anonymous unions public whereas clang++ complains see this post http://jonmacey.blogspot.com/2011/03/anonymous-union-struct-weirdness.html

Definition at line 146 of file Colour.h.

Member Data Documentation

Real ngl::Colour::m_a

alpha the transparent element

Definition at line 172 of file Colour.h.

Real ngl::Colour::m_b

blue component of the colour tuple

Definition at line 168 of file Colour.h.

Real ngl::Colour::m_g

green component of the colour tuple

Definition at line 164 of file Colour.h.

Real ngl::Colour::m_openGL[4]

The data as an array of 4 floats useful for passing to OpenGL fv data types this is mapped as a union to the following
m_r == m_openGL[0]
m_g == m_openGL[1]
m_b == m_openGL[2]
m_a == m_openGL[3]
.

Definition at line 184 of file Colour.h.

Real ngl::Colour::m_r

red component of the colour tuple

Definition at line 160 of file Colour.h.


The documentation for this class was generated from the following files: