Math API nvidia_logo_transpbg.gif Up
mi::math::Color Class Reference

Standard RGBA color class with floating point elements and operations. More...

#include <color.h>

Inheritance diagram for mi::math::Color:

Public Types

typedef Color_struct Pod_type
 POD class corresponding to this color. More...
 
typedef Color_struct storage_type
 Storage class used by this color. More...
 
typedef Float32 value_type
 Element type. More...
 
typedef Size size_type
 Size type, unsigned. More...
 
typedef Difference difference_type
 Difference type, signed. More...
 
typedef Float32pointer
 Mutable pointer to element. More...
 
typedef const Float32const_pointer
 Const pointer to element. More...
 
typedef Float32reference
 Mutable reference to element. More...
 
typedef const Float32const_reference
 Const reference to element. More...
 

Public Member Functions

Float32begin ()
 Returns the pointer to the first color element. More...
 
const Float32begin () const
 Returns the pointer to the first color element. More...
 
Float32end ()
 Returns the past-the-end pointer. More...
 
const Float32end () const
 Returns the past-the-end pointer. More...
 
 Color ()
 The default constructor leaves the color elements uninitialized. More...
 
 Color (const Color &c)=default
 Default copy constructor. More...
 
 Color (const Color_struct &c)
 Constructor from underlying storage type. More...
 
 Color (const Float32 s)
 Constructor initializes all vector elements to the value s. More...
 
 Color (Float32 nr, Float32 ng, Float32 nb, Float32 na=1.0)
 Constructor initializes (r,g,b,a) from (nr,ng,nb,na). More...
 
template<typename T>
 Color (T array[4])
 Constructor initializes the color elements from a 4-dimensional array. More...
 
 Color (const Vector< Float32, 4 > &v)
 Constructor initializes (r,g,b,a) from (v.x, v.y, v.z, v.w) of a compatible 4D vector v. More...
 
 Color (const Spectrum_struct &s)
 Conversion from Spectrum. More...
 
Coloroperator= (const Color &c)
 Assignment operator. More...
 
Coloroperator= (const Vector< Float32, 4 > &v)
 Assignment operator from compatible 4D vector, setting (r,g,b,a) to (v.x, v.y, v.z, v.w). More...
 
const Float32operator[] (Size i) const
 Accesses the i-th color element, 0 <= i < 4. More...
 
Float32operator[] (Size i)
 Accesses the i-th color element, 0 <= i < 4. More...
 
Float32 get (Size i) const
 Returns the i-th color element, 0 <= i < 4. More...
 
void set (Size i, Float32 value)
 Sets the i-th color element to value, 0 <= i < 4. More...
 
bool is_black () const
 Returns true if the color is black ignoring the alpha value. More...
 
Float32 linear_intensity () const
 Returns the intensity of the RGB components, equally weighted. More...
 
Float32 ntsc_intensity () const
 Returns the intensity of the RGB components, weighted according to the NTSC standard. More...
 
Float32 cie_intensity () const
 Returns the intensity of the RGB components, weighted according to the CIE standard. More...
 
Color clip (Clip_mode mode=CLIP_RGB, bool desaturate=false) const
 Returns this color clipped into the [0,1] range, according to the Clip_mode mode, and fades overbright colors to white if desaturate is true. More...
 
Color desaturate (Float32 maxval=1.0f) const
 Returns this color clipped to the range [0,maxval] using color desaturation. More...
 

Static Public Member Functions

static Size size ()
 Constant size of the color. More...
 
static Size max_size ()
 Constant maximum size of the color. More...
 

Public Attributes

Float32 r
 Red color component. More...
 
Float32 g
 Green color component. More...
 
Float32 b
 Blue color component. More...
 
Float32 a
 Alpha value, 0.0 is fully transparent and 1.0 is opaque; value can lie outside that range. More...
 

Static Public Attributes

static const Size SIZE = 4
 Constant size of the color. More...
 

Detailed Description

Standard RGBA color class with floating point elements and operations.

This class provides array-like storage for the four RGBA elements of type mi::Float32. Several functions and arithmetic operators support the work with colors.

The color class is a model of the STL container concept. It provides random access to its elements and corresponding random access iterators.

See also
For the free functions and operators available for colors see Color Class.
The underlying POD type mi::math::Color_struct.
Include File:
#include <mi/math/color.h>