Standard RGBA color class with floating point elements and operations. More...
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 Float32 * | pointer |
Mutable pointer to element. More... |
|
typedef const Float32 * | const_pointer |
Const pointer to element. More... |
|
typedef Float32 & | reference |
Mutable reference to element. More... |
|
typedef const Float32 & | const_reference |
Const reference to element. More... |
|
Public Member Functions | |
Float32 * | begin () |
Returns the pointer to the first color element. More... |
|
const Float32 * | begin () const |
Returns the pointer to the first color element. More... |
|
Float32 * | end () |
Returns the past-the-end pointer. More... |
|
const Float32 * | end () const |
Returns the past-the-end pointer. More... |
|
Color () | |
The default constructor leaves the color elements uninitialized. 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... |
|
Color & | operator= (const Color &c) |
Assignment operator. More... |
|
Color & | operator= (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 Float32 & | operator[] (Size i) const |
Accesses the i-th color element, 0 <= i < 4 . More... |
|
Float32 & | operator[] (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... |
|
Static Public Attributes | |
static const Size | SIZE = 4 |
Constant size of the color. More... |
|
Additional Inherited Members | |
Public Attributes inherited from mi::math::Color_struct | |
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... |
|
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.
#include <mi/math/color.h>
typedef const Float32* mi::math::Color::const_pointer |
Const pointer to element.
typedef const Float32& mi::math::Color::const_reference |
Const reference to element.
Difference type, signed.
POD class corresponding to this color.
typedef Float32* mi::math::Color::pointer |
Mutable pointer to element.
typedef Float32& mi::math::Color::reference |
Mutable reference to element.
typedef Size mi::math::Color::size_type |
Size type, unsigned.
Storage class used by this color.
typedef Float32 mi::math::Color::value_type |
Element type.
|
inline |
The default constructor leaves the color elements uninitialized.
|
inline |
Constructor from underlying storage type.
|
inlineexplicit |
Constructor initializes all vector elements to the value s
.
Constructor initializes (r,g,b,a) from (nr
,ng
,nb
,na
).
|
inlineexplicit |
Constructor initializes the color elements from a 4-dimensional array
.
The value type T
of the array
must be assignment compatible with the mi::Float32 type of the vector elements.
An example defining a red color:
Constructor initializes (r,g,b,a) from (v.x
, v.y
, v.z
, v.w
) of a compatible 4D vector v
.
|
inlineexplicit |
Conversion from Spectrum.
|
inline |
Returns the pointer to the first color element.
|
inline |
Returns the pointer to the first color element.
|
inline |
Returns the intensity of the RGB components, weighted according to the CIE standard.
Components are weighted to match the subjective color brightness perceived by the human eye; green appears brighter than blue.
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
.
Returns this color clipped to the range [0,maxval
] using color desaturation.
This function tries to maintain the apparent brightness. It recognizes the brightness values of the different colors according to the NTSC standard. If possible, colors are adjusted by desaturating towards the brightness value.
For an explanation of color clipping using desaturation, see pp. 125-128 and pp. 251-252 of "Illumination and Color in Computer Generated Imagery" by Roy Hall.
|
inline |
|
inline |
|
inline |
Returns true
if the color is black ignoring the alpha value.
|
inline |
Returns the intensity of the RGB components, equally weighted.
|
inlinestatic |
Constant maximum size of the color.
|
inline |
Returns the intensity of the RGB components, weighted according to the NTSC standard.
Components are weighted to match the subjective color brightness perceived by the human eye; green appears brighter than blue.
Assignment operator from compatible 4D vector, setting (r,g,b,a) to (v.x
, v.y
, v.z
, v.w
).
Accesses the i-th
color element, 0 <= i < 4
.
Sets the i-th
color element to value
, 0 <= i < 4
.
|
inlinestatic |
Constant size of the color.
|
static |
Constant size of the color.