cgv
Loading...
Searching...
No Matches
cgv::media::color< T, cm, am > Class Template Reference

represent a color with components of given type and color and alpha model as specified. More...

#include <color.h>

Inheritance diagram for cgv::media::color< T, cm, am >:
cgv::media::extinction_alpha_interface< color< T, cm, am > > cgv::media::transparency_alpha_interface< color< T, cm, am > > cgv::media::opacity_alpha_interface< color< T, cm, am > > cgv::media::xyz_color_interface< color< T, cm, am > > cgv::media::hls_color_interface< color< T, cm, am > > cgv::media::rgb_color_interface< color< T, cm, am > > cgv::media::color_base< T, cm, am >

Public Types

typedef T component_type
 type of color components
 
- Public Types inherited from cgv::media::color_base< T, cm, am >
typedef T component_type
 type of color components
 

Public Member Functions

 color ()
 standard constructor does not initialize components
 
 color (const T &c)
 set all components to given value
 
 color (const T &c0, const T &c1)
 set first two components to given values
 
 color (const T &c0, const T &c1, const T &c2)
 set first three components to given values
 
 color (const T &c0, const T &c1, const T &c2, const T &c3)
 set all four components to given values
 
 color (const color< T, cm > &c, T a)
 construct from non-alpha color plus alpha
 
template<typename T2 , ColorModel cm2, AlphaModel am2>
 color (const color< T2, cm2, am2 > &c2)
 copy constructor uses color conversion if necessary
 
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > & operator= (const color< T2, cm2, am2 > &c2)
 assign to color with potential color conversion
 
color< T, cm, am > & operator= (const T &c)
 assign all components including alpha to c
 
color< T, cm > & drop_alpha ()
 drop the alpha component if any by a cast operator
 
const color< T, cm > & drop_alpha () const
 
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > & operator*= (const color< T2, cm2, am2 > &c2)
 multiply with color
 
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > operator* (const color< T2, cm2, am2 > &c2)
 post multiply with color
 
color< T, cm, am > & operator*= (const T &c)
 multiply with constant
 
template<typename T2 >
color< typename type::func::promote< T, T2 >::type, cm, am > operator* (const T2 &c) const
 post multiply with constant
 
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > & operator+= (const color< T2, cm2, am2 > &c2)
 add color
 
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > operator+ (const color< T2, cm2, am2 > &c2)
 add color
 
color< T, cm, am > & operator+= (const T &c)
 add constant
 
color< T, cm, am > operator+ (const T &c)
 add constant
 
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > & operator-= (const color< T2, cm2, am2 > &c2)
 subtract color
 
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > operator- (const color< T2, cm2, am2 > &c2)
 subtract color
 
color< T, cm, am > & operator-= (const T &c)
 subtract constant
 
color< T, cm, am > operator- (const T &c)
 subtract constant
 
void clamp (const T &mn=0, const T &mx=color_one< T >::value(), bool skip_alpha=false)
 clamp to the given range, which defaults to [0,1] of the component type
 
T & operator[] (unsigned int i)
 access to components
 
const T & operator[] (unsigned int i) const
 const access to components
 
- Public Member Functions inherited from cgv::media::extinction_alpha_interface< color< T, cm, am > >
extinction () const
 convert alpha to extinction
 
- Public Member Functions inherited from cgv::media::transparency_alpha_interface< color< T, cm, am > >
transparency () const
 convert alpha to transparency
 
- Public Member Functions inherited from cgv::media::opacity_alpha_interface< color< T, cm, am > >
opacity () const
 convert alpha to opacity
 
- Public Member Functions inherited from cgv::media::xyz_color_interface< color< T, cm, am > >
X () const
 convert color to XYZ and return X component
 
Y () const
 convert color to XYZ and return Y component
 
Z () const
 convert color to XYZ and return Z component
 
- Public Member Functions inherited from cgv::media::hls_color_interface< color< T, cm, am > >
H () const
 convert color to HLS and return H component
 
L () const
 convert color to HLS and return L component
 
S () const
 convert color to HLS and return S component
 
- Public Member Functions inherited from cgv::media::rgb_color_interface< color< T, cm, am > >
R () const
 convert color to RGB and return R component
 
G () const
 convert color to RGB and return G component
 
B () const
 convert color to RGB and return B component
 
- Public Member Functions inherited from cgv::media::color_base< T, cm, am >
 color_base ()
 standard constructor does not initialize components
 
 color_base (const color_base< T2, cm2, am2 > &c2)
 copy constructor uses color conversion if necessary
 
T & at (unsigned int i)
 access to components
 
const T & at (unsigned int i) const
 const access to components
 
T & alpha ()
 return alpha component
 
const T & alpha () const
 return alpha component
 

Static Public Attributes

static const ColorModel clr_mod = cm
 static and const access to color model
 
static const AlphaModel alp_mod = am
 static and const access to alpha model
 
static const unsigned int nr_color_components = color_base<T,cm,am>::nr_color_components
 static and const access to number of color components
 
static const unsigned int nr_alpha_components = color_base<T, cm, am>::nr_alpha_components
 static and const access to number of alpha components
 
static const unsigned int nr_components = color_base<T, cm, am>::nr_components
 static and const access to total number of components
 
- Static Public Attributes inherited from cgv::media::color_base< T, cm, am >
static const unsigned int nr_color_components
 static and const access to number of color components
 
static const unsigned int nr_alpha_components
 static and const access to number of alpha components
 
static const unsigned int nr_components
 static and const access to total number of components
 

Additional Inherited Members

- Protected Attributes inherited from cgv::media::color_base< T, cm, am >
components [nr_components]
 

Detailed Description

template<typename T, ColorModel cm, AlphaModel am>
class cgv::media::color< T, cm, am >

represent a color with components of given type and color and alpha model as specified.

Definition at line 573 of file color.h.

Member Typedef Documentation

◆ component_type

template<typename T , ColorModel cm, AlphaModel am>
typedef T cgv::media::color< T, cm, am >::component_type

type of color components

Definition at line 587 of file color.h.

Constructor & Destructor Documentation

◆ color() [1/7]

template<typename T , ColorModel cm, AlphaModel am>
cgv::media::color< T, cm, am >::color ( )
inline

standard constructor does not initialize components

Definition at line 589 of file color.h.

◆ color() [2/7]

template<typename T , ColorModel cm, AlphaModel am>
cgv::media::color< T, cm, am >::color ( const T &  c)
inline

set all components to given value

Definition at line 591 of file color.h.

◆ color() [3/7]

template<typename T , ColorModel cm, AlphaModel am>
cgv::media::color< T, cm, am >::color ( const T &  c0,
const T &  c1 
)
inline

set first two components to given values

Definition at line 593 of file color.h.

References cgv::media::color< T, cm, am >::nr_components.

◆ color() [4/7]

template<typename T , ColorModel cm, AlphaModel am>
cgv::media::color< T, cm, am >::color ( const T &  c0,
const T &  c1,
const T &  c2 
)
inline

set first three components to given values

Definition at line 599 of file color.h.

References cgv::media::color< T, cm, am >::nr_components.

◆ color() [5/7]

template<typename T , ColorModel cm, AlphaModel am>
cgv::media::color< T, cm, am >::color ( const T &  c0,
const T &  c1,
const T &  c2,
const T &  c3 
)
inline

set all four components to given values

Definition at line 607 of file color.h.

References cgv::media::color< T, cm, am >::nr_components.

◆ color() [6/7]

template<typename T , ColorModel cm, AlphaModel am>
cgv::media::color< T, cm, am >::color ( const color< T, cm > &  c,
a 
)
inline

construct from non-alpha color plus alpha

Definition at line 617 of file color.h.

References cgv::media::color_base< T, cm, am >::at(), and cgv::media::color< T, cm, am >::nr_color_components.

◆ color() [7/7]

template<typename T , ColorModel cm, AlphaModel am>
template<typename T2 , ColorModel cm2, AlphaModel am2>
cgv::media::color< T, cm, am >::color ( const color< T2, cm2, am2 > &  c2)
inline

copy constructor uses color conversion if necessary

Definition at line 624 of file color.h.

Member Function Documentation

◆ clamp()

template<typename T , ColorModel cm, AlphaModel am>
void cgv::media::color< T, cm, am >::clamp ( const T &  mn = 0,
const T &  mx = color_one<T>::value(),
bool  skip_alpha = false 
)
inline

clamp to the given range, which defaults to [0,1] of the component type

Definition at line 725 of file color.h.

References cgv::media::color_base< T, cm, am >::at(), cgv::media::color< T, cm, am >::nr_color_components, and cgv::media::color< T, cm, am >::nr_components.

◆ drop_alpha() [1/2]

template<typename T , ColorModel cm, AlphaModel am>
color< T, cm > & cgv::media::color< T, cm, am >::drop_alpha ( )
inline

drop the alpha component if any by a cast operator

Definition at line 639 of file color.h.

◆ drop_alpha() [2/2]

template<typename T , ColorModel cm, AlphaModel am>
const color< T, cm > & cgv::media::color< T, cm, am >::drop_alpha ( ) const
inline

Definition at line 640 of file color.h.

◆ operator*() [1/2]

template<typename T , ColorModel cm, AlphaModel am>
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > cgv::media::color< T, cm, am >::operator* ( const color< T2, cm2, am2 > &  c2)
inline

post multiply with color

Definition at line 651 of file color.h.

◆ operator*() [2/2]

template<typename T , ColorModel cm, AlphaModel am>
template<typename T2 >
color< typename type::func::promote< T, T2 >::type, cm, am > cgv::media::color< T, cm, am >::operator* ( const T2 &  c) const
inline

post multiply with constant

Definition at line 664 of file color.h.

References cgv::media::color_base< T, cm, am >::at(), and cgv::media::color< T, cm, am >::nr_components.

◆ operator*=() [1/2]

template<typename T , ColorModel cm, AlphaModel am>
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > & cgv::media::color< T, cm, am >::operator*= ( const color< T2, cm2, am2 > &  c2)
inline

multiply with color

Definition at line 643 of file color.h.

References cgv::media::color_base< T, cm, am >::at(), and cgv::media::color< T, cm, am >::nr_components.

◆ operator*=() [2/2]

template<typename T , ColorModel cm, AlphaModel am>
color< T, cm, am > & cgv::media::color< T, cm, am >::operator*= ( const T &  c)
inline

multiply with constant

Definition at line 657 of file color.h.

References cgv::media::color_base< T, cm, am >::at(), and cgv::media::color< T, cm, am >::nr_components.

◆ operator+() [1/2]

template<typename T , ColorModel cm, AlphaModel am>
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > cgv::media::color< T, cm, am >::operator+ ( const color< T2, cm2, am2 > &  c2)
inline

add color

Definition at line 680 of file color.h.

◆ operator+() [2/2]

template<typename T , ColorModel cm, AlphaModel am>
color< T, cm, am > cgv::media::color< T, cm, am >::operator+ ( const T &  c)
inline

add constant

Definition at line 692 of file color.h.

◆ operator+=() [1/2]

template<typename T , ColorModel cm, AlphaModel am>
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > & cgv::media::color< T, cm, am >::operator+= ( const color< T2, cm2, am2 > &  c2)
inline

◆ operator+=() [2/2]

template<typename T , ColorModel cm, AlphaModel am>
color< T, cm, am > & cgv::media::color< T, cm, am >::operator+= ( const T &  c)
inline

◆ operator-() [1/2]

template<typename T , ColorModel cm, AlphaModel am>
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > cgv::media::color< T, cm, am >::operator- ( const color< T2, cm2, am2 > &  c2)
inline

subtract color

Definition at line 707 of file color.h.

◆ operator-() [2/2]

template<typename T , ColorModel cm, AlphaModel am>
color< T, cm, am > cgv::media::color< T, cm, am >::operator- ( const T &  c)
inline

subtract constant

Definition at line 719 of file color.h.

◆ operator-=() [1/2]

template<typename T , ColorModel cm, AlphaModel am>
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > & cgv::media::color< T, cm, am >::operator-= ( const color< T2, cm2, am2 > &  c2)
inline

subtract color

Definition at line 699 of file color.h.

References cgv::media::color_base< T, cm, am >::at(), and cgv::media::color< T, cm, am >::nr_components.

◆ operator-=() [2/2]

template<typename T , ColorModel cm, AlphaModel am>
color< T, cm, am > & cgv::media::color< T, cm, am >::operator-= ( const T &  c)
inline

subtract constant

Definition at line 713 of file color.h.

References cgv::media::color_base< T, cm, am >::at(), and cgv::media::color< T, cm, am >::nr_components.

◆ operator=() [1/2]

template<typename T , ColorModel cm, AlphaModel am>
template<typename T2 , ColorModel cm2, AlphaModel am2>
color< T, cm, am > & cgv::media::color< T, cm, am >::operator= ( const color< T2, cm2, am2 > &  c2)
inline

assign to color with potential color conversion

Definition at line 629 of file color.h.

◆ operator=() [2/2]

template<typename T , ColorModel cm, AlphaModel am>
color< T, cm, am > & cgv::media::color< T, cm, am >::operator= ( const T &  c)
inline

assign all components including alpha to c

Definition at line 634 of file color.h.

References cgv::media::color< T, cm, am >::nr_components.

◆ operator[]() [1/2]

template<typename T , ColorModel cm, AlphaModel am>
T & cgv::media::color< T, cm, am >::operator[] ( unsigned int  i)
inline

access to components

Definition at line 734 of file color.h.

References cgv::media::color_base< T, cm, am >::at().

◆ operator[]() [2/2]

template<typename T , ColorModel cm, AlphaModel am>
const T & cgv::media::color< T, cm, am >::operator[] ( unsigned int  i) const
inline

const access to components

Definition at line 736 of file color.h.

References cgv::media::color_base< T, cm, am >::at().

Member Data Documentation

◆ alp_mod

template<typename T , ColorModel cm, AlphaModel am>
const AlphaModel cgv::media::color< T, cm, am >::alp_mod = am
static

static and const access to alpha model

Definition at line 579 of file color.h.

◆ clr_mod

template<typename T , ColorModel cm, AlphaModel am>
const ColorModel cgv::media::color< T, cm, am >::clr_mod = cm
static

static and const access to color model

Definition at line 577 of file color.h.

◆ nr_alpha_components

template<typename T , ColorModel cm, AlphaModel am>
const unsigned int cgv::media::color< T, cm, am >::nr_alpha_components = color_base<T, cm, am>::nr_alpha_components
static

static and const access to number of alpha components

Definition at line 583 of file color.h.

◆ nr_color_components

template<typename T , ColorModel cm, AlphaModel am>
const unsigned int cgv::media::color< T, cm, am >::nr_color_components = color_base<T,cm,am>::nr_color_components
static

static and const access to number of color components

Definition at line 581 of file color.h.

Referenced by cgv::media::color< T, cm, am >::clamp(), and cgv::media::color< T, cm, am >::color().

◆ nr_components


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