library of assembled shared sources

http://lass.cocamware.com

lass::prim::ColorRGBA Struct Reference

an [0, 1] floating point RGB colour with Alpha channel. More...

#include <color_rgba.h>


Public Types

enum  { dimension = 4 }
typedef Vector4D< float > TVector
typedef TVector::TValue TValue
typedef TVector::TParam TParam
typedef TVector::TReference TReference
typedef TVector::TConstReference TConstReference
typedef TVector::TNumTraits TNumTraits

Public Member Functions

 ColorRGBA ()
 construct an unexisting color (black with zero alpha)
 ColorRGBA (TParam iRed, TParam iGreen, TParam iBlue, TParam iAlpha=ColorRGBA::TNumTraits::one)
 construct a color with values for all channels
 ColorRGBA (TParam iWhite, TParam iAlpha=ColorRGBA::TNumTraits::one)
 construct a color in white range (r == g == b), with an alpha value
 ColorRGBA (const TVector &iVector)
 construct a color from a raw vector
const TVector vector () const
TConstReference operator[] (unsigned iIndex) const
TReference operator[] (unsigned iIndex)
TConstReference at (signed iIndex) const
TReference at (signed iIndex)
const ColorRGBAoperator+ () const
const ColorRGBA operator- () const
ColorRGBAoperator+= (const ColorRGBA &iOther)
 raw addition of iOther to this color, including alpha channel
ColorRGBAoperator-= (const ColorRGBA &iOther)
 raw subtraction iOther from this color, including alpha channel
ColorRGBAoperator*= (const ColorRGBA &iOther)
 raw multiplication of iOther with this color, including alpha channel
ColorRGBAoperator/= (const ColorRGBA &iOther)
 raw division of this color by iOther, including alpha channel
ColorRGBAoperator+= (TParam iWhite)
 raw addition of iWhite to this color, including alpha channel
ColorRGBAoperator-= (TParam iWhite)
 raw subtraction iWhite from this color, including alpha channel
ColorRGBAoperator*= (TParam iWhite)
 raw multiplication of iWhite with this color, including alpha channel
ColorRGBAoperator/= (TParam iWhite)
 raw division of this color by iWhite, including alpha channel
const TValue brightness () const
const bool isBlack () const
 return true if all color components are zero
const bool isZero () const
 return true if all components are zero
const bool isNaN () const
 Return true if at least one of the components is NaN.
const ColorRGBA darkened (TParam iFactor) const
 return darkened colour without changing the opaqueness.
const ColorRGBA dissolved (TParam iFactor) const
 return color with dissolved opaqueness
const ColorRGBA gammaCorrected (TParam iGamma) const
 return gamma corrected color.
const ColorRGBA exposed (TParam iTime) const
 return exposed color.
const ColorRGBA invExposed (TParam iTime) const
 return result of inverse exposure function
const ColorRGBA clamped () const
 clamp all channels (including alpha channel) to the range [0, 1].

Static Public Member Functions

static const ColorRGBA mapAutumn (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'autumn' of matlab.
static const ColorRGBA mapBone (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'bone' of matlab.
static const ColorRGBA mapCool (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'cool' of matlab.
static const ColorRGBA mapCopper (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'copper' of matlab.
static const ColorRGBA mapGray (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'gray' of matlab.
static const ColorRGBA mapHot (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'hot' of matlab.
static const ColorRGBA mapHsv (TParam iValue)
 convert a value to a color like in colormap 'hsv' of matlab.
static const ColorRGBA mapJet (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'jet' of matlab.
static const ColorRGBA mapPink (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'pink' of matlab.
static const ColorRGBA mapSpring (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'spring' of matlab.
static const ColorRGBA mapSummer (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'summer' of matlab.
static const ColorRGBA mapWinter (TParam iValue)
 convert a value in range [0, 1] to a color like in colormap 'winter' of matlab.
static const ColorRGBA mapCustom (TParam iValue, const std::vector< ColorRGBA > &iColorMap)
 convert a value in range [0, 1] to a color from a custom color map.

Data Fields

TValue r
TValue g
TValue b
TValue a

Static Private Member Functions

static const ColorRGBA doMap (TParam iValue, const ColorRGBA *iMap, int iMapSize)

Related Functions

(Note that these are not member functions.)

ColorRGBA operator+ (const ColorRGBA &iA, const ColorRGBA &iB)
 raw addition of iA and iB, including alpha channels
ColorRGBA operator- (const ColorRGBA &iA, const ColorRGBA &iB)
 raw subtraction of iA and iB, including alpha channels
ColorRGBA operator* (const ColorRGBA &iA, const ColorRGBA &iB)
 raw addition of iA and iB, including alpha channels
ColorRGBA operator/ (const ColorRGBA &iA, const ColorRGBA &iB)
 raw addition of iA and iB, including alpha channels
ColorRGBA operator+ (ColorRGBA::TParam iA, const ColorRGBA &iB)
 raw addition of iA and iB, including alpha channels
ColorRGBA operator- (ColorRGBA::TParam iA, const ColorRGBA &iB)
 raw subtraction of iA and iB, including alpha channels
ColorRGBA operator* (ColorRGBA::TParam iA, const ColorRGBA &iB)
 raw addition of iA and iB, including alpha channels
ColorRGBA operator/ (ColorRGBA::TParam iA, const ColorRGBA &iB)
 raw addition of iA and iB, including alpha channels
ColorRGBA operator+ (const ColorRGBA &iA, ColorRGBA::TParam iB)
 raw addition of iA and iB, including alpha channels
ColorRGBA operator- (const ColorRGBA &iA, ColorRGBA::TParam iB)
 raw subtraction of iA and iB, including alpha channels
ColorRGBA operator* (const ColorRGBA &iA, ColorRGBA::TParam iB)
 raw addition of iA and iB, including alpha channels
ColorRGBA operator/ (const ColorRGBA &iA, ColorRGBA::TParam iB)
 raw addition of iA and iB, including alpha channels


Detailed Description

an [0, 1] floating point RGB colour with Alpha channel.

Author:
Bram de Greve [BdG]

Definition at line 61 of file color_rgba.h.


Member Typedef Documentation

Definition at line 65 of file color_rgba.h.

Definition at line 67 of file color_rgba.h.

Definition at line 68 of file color_rgba.h.

Definition at line 69 of file color_rgba.h.

Definition at line 70 of file color_rgba.h.

Definition at line 71 of file color_rgba.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
dimension 

Definition at line 73 of file color_rgba.h.


Constructor & Destructor Documentation

lass::prim::ColorRGBA::ColorRGBA (  ) 

construct an unexisting color (black with zero alpha)

Definition at line 64 of file color_rgba.cpp.

References isZero(), and LASS_ASSERT.

Referenced by clamped(), exposed(), gammaCorrected(), invExposed(), mapAutumn(), mapBone(), mapCool(), mapCopper(), mapGray(), mapHot(), mapHsv(), mapJet(), mapPink(), mapSpring(), mapSummer(), and mapWinter().

lass::prim::ColorRGBA::ColorRGBA ( TParam  iRed,
TParam  iGreen,
TParam  iBlue,
TParam  iAlpha = ColorRGBA::TNumTraits::one 
)

construct a color with values for all channels

Definition at line 77 of file color_rgba.cpp.

lass::prim::ColorRGBA::ColorRGBA ( TParam  iWhite,
TParam  iAlpha = ColorRGBA::TNumTraits::one 
) [explicit]

construct a color in white range (r == g == b), with an alpha value

Definition at line 89 of file color_rgba.cpp.

lass::prim::ColorRGBA::ColorRGBA ( const TVector iVector  )  [explicit]

construct a color from a raw vector

Definition at line 101 of file color_rgba.cpp.


Member Function Documentation

const TVector lass::prim::ColorRGBA::vector (  )  const [inline]

Definition at line 88 of file color_rgba.h.

TConstReference lass::prim::ColorRGBA::operator[] ( unsigned  iIndex  )  const [inline]

Definition at line 89 of file color_rgba.h.

TReference lass::prim::ColorRGBA::operator[] ( unsigned  iIndex  )  [inline]

Definition at line 90 of file color_rgba.h.

TConstReference lass::prim::ColorRGBA::at ( signed  iIndex  )  const [inline]

Definition at line 91 of file color_rgba.h.

References lass::num::mod().

TReference lass::prim::ColorRGBA::at ( signed  iIndex  )  [inline]

Definition at line 92 of file color_rgba.h.

References lass::num::mod().

const ColorRGBA& lass::prim::ColorRGBA::operator+ (  )  const

const ColorRGBA lass::prim::ColorRGBA::operator- (  )  const

ColorRGBA & lass::prim::ColorRGBA::operator+= ( const ColorRGBA iOther  ) 

raw addition of iOther to this color, including alpha channel

Definition at line 113 of file color_rgba.cpp.

References a, b, g, and r.

ColorRGBA & lass::prim::ColorRGBA::operator-= ( const ColorRGBA iOther  ) 

raw subtraction iOther from this color, including alpha channel

Definition at line 126 of file color_rgba.cpp.

References a, b, g, and r.

ColorRGBA & lass::prim::ColorRGBA::operator*= ( const ColorRGBA iOther  ) 

raw multiplication of iOther with this color, including alpha channel

Definition at line 139 of file color_rgba.cpp.

References a, b, g, and r.

ColorRGBA & lass::prim::ColorRGBA::operator/= ( const ColorRGBA iOther  ) 

raw division of this color by iOther, including alpha channel

Definition at line 152 of file color_rgba.cpp.

References a, b, g, and r.

ColorRGBA & lass::prim::ColorRGBA::operator+= ( TParam  iWhite  ) 

raw addition of iWhite to this color, including alpha channel

Definition at line 165 of file color_rgba.cpp.

References a, b, g, and r.

ColorRGBA & lass::prim::ColorRGBA::operator-= ( TParam  iWhite  ) 

raw subtraction iWhite from this color, including alpha channel

Definition at line 178 of file color_rgba.cpp.

References a, b, g, and r.

ColorRGBA & lass::prim::ColorRGBA::operator*= ( TParam  iWhite  ) 

raw multiplication of iWhite with this color, including alpha channel

Definition at line 191 of file color_rgba.cpp.

References a, b, g, and r.

ColorRGBA & lass::prim::ColorRGBA::operator/= ( TParam  iWhite  ) 

raw division of this color by iWhite, including alpha channel

Definition at line 204 of file color_rgba.cpp.

References a, b, g, lass::num::NumTraits< C >::one, and r.

const ColorRGBA::TValue lass::prim::ColorRGBA::brightness (  )  const

Definition at line 216 of file color_rgba.cpp.

References b, g, and r.

const bool lass::prim::ColorRGBA::isBlack (  )  const

return true if all color components are zero

Definition at line 225 of file color_rgba.cpp.

References b, g, r, and lass::num::NumTraits< C >::zero.

const bool lass::prim::ColorRGBA::isZero (  )  const

return true if all components are zero

Definition at line 234 of file color_rgba.cpp.

References a, b, g, r, and lass::num::NumTraits< C >::zero.

Referenced by ColorRGBA().

const bool lass::prim::ColorRGBA::isNaN (  )  const

Return true if at least one of the components is NaN.

Definition at line 244 of file color_rgba.cpp.

References a, b, g, and r.

const ColorRGBA lass::prim::ColorRGBA::darkened ( ColorRGBA::TParam  iFactor  )  const

return darkened colour without changing the opaqueness.

Precondition:
*this are considered non-premultiplied
  alphaR = alphaA.
  ColorR = ColorA * darkenFactor.

  • T. Porter, T. Duff. Compositing Digital Images, Comp. Graphics, 18(3):253-259, July 1984.

Definition at line 262 of file color_rgba.cpp.

References a.

const ColorRGBA lass::prim::ColorRGBA::dissolved ( TParam  iFactor  )  const

return color with dissolved opaqueness

Precondition:
iA and iB are considered non-premultiplied
  alphaR = alphaA * dissolveFactor.
  ColorR = ColorA.

  • T. Porter, T. Duff. Compositing Digital Images, Comp. Graphics, 18(3):253-259, July 1984.

Definition at line 283 of file color_rgba.cpp.

References a.

const ColorRGBA lass::prim::ColorRGBA::gammaCorrected ( TParam  iGammaExponent  )  const

return gamma corrected color.

corrects gamma of all channels, except alpha.

Precondition:
iA and iB are considered non-premultiplied
  alphaR = alphaA.
  ColorR = ColorA ** (1 / gamma).

Definition at line 303 of file color_rgba.cpp.

References a, b, ColorRGBA(), g, lass::num::inv(), lass::num::pow(), and r.

const ColorRGBA lass::prim::ColorRGBA::exposed ( TParam  iExposureTime  )  const

return exposed color.

apply exposure function to color and clamp alpha channel

Precondition:
iA and iB are considered non-premultiplied
Postcondition:
: all channel values ar in the range [0, 1].
  alphaR = alphaA.
  ColorR = 1 - exp(-time * ColorA).

Definition at line 323 of file color_rgba.cpp.

References a, b, lass::num::clamp(), ColorRGBA(), lass::num::exp(), g, lass::num::NumTraits< C >::one, r, and lass::num::NumTraits< C >::zero.

const ColorRGBA lass::prim::ColorRGBA::invExposed ( TParam  iExposureTime  )  const

return result of inverse exposure function

apply inverse of exposure function to color and clamp alpha channel

Precondition:
iA and iB are considered non-premultiplied
Postcondition:
: all channel values ar in the range [0, 1].
  alphaR = alphaA.
  ColorR = log(1 - colorA) / -time

Definition at line 347 of file color_rgba.cpp.

References a, b, lass::num::clamp(), ColorRGBA(), g, lass::num::inv(), lass::num::log(), lass::num::NumTraits< C >::minStrictPositive, lass::num::NumTraits< C >::one, and r.

const ColorRGBA lass::prim::ColorRGBA::clamped (  )  const

clamp all channels (including alpha channel) to the range [0, 1].

Postcondition:
: all channel values ar in the range [0, 1].

Definition at line 362 of file color_rgba.cpp.

References a, b, lass::num::clamp(), ColorRGBA(), g, lass::num::NumTraits< C >::one, r, and lass::num::NumTraits< C >::zero.

const ColorRGBA lass::prim::ColorRGBA::mapAutumn ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'autumn' of matlab.

Definition at line 375 of file color_rgba.cpp.

References ColorRGBA(), inpclamp(), lass::num::NumTraits< C >::one, and lass::num::NumTraits< C >::zero.

const ColorRGBA lass::prim::ColorRGBA::mapBone ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'bone' of matlab.

Definition at line 385 of file color_rgba.cpp.

References ColorRGBA(), and doMap().

const ColorRGBA lass::prim::ColorRGBA::mapCool ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'cool' of matlab.

Definition at line 401 of file color_rgba.cpp.

References ColorRGBA(), inpclamp(), lass::num::NumTraits< C >::one, and lass::num::NumTraits< C >::zero.

const ColorRGBA lass::prim::ColorRGBA::mapCopper ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'copper' of matlab.

Definition at line 411 of file color_rgba.cpp.

References ColorRGBA(), inpclamp(), lass::num::NumTraits< C >::one, and lass::num::NumTraits< C >::zero.

const ColorRGBA lass::prim::ColorRGBA::mapGray ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'gray' of matlab.

Definition at line 421 of file color_rgba.cpp.

References ColorRGBA(), inpclamp(), lass::num::NumTraits< C >::one, and lass::num::NumTraits< C >::zero.

const ColorRGBA lass::prim::ColorRGBA::mapHot ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'hot' of matlab.

Definition at line 431 of file color_rgba.cpp.

References ColorRGBA(), and doMap().

const ColorRGBA lass::prim::ColorRGBA::mapHsv ( TParam  iValue  )  [static]

convert a value to a color like in colormap 'hsv' of matlab.

Definition at line 452 of file color_rgba.cpp.

References ColorRGBA(), doMap(), and lass::num::floor().

const ColorRGBA lass::prim::ColorRGBA::mapJet ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'jet' of matlab.

Definition at line 471 of file color_rgba.cpp.

References ColorRGBA(), and doMap().

const ColorRGBA lass::prim::ColorRGBA::mapPink ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'pink' of matlab.

Definition at line 493 of file color_rgba.cpp.

References ColorRGBA(), and doMap().

const ColorRGBA lass::prim::ColorRGBA::mapSpring ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'spring' of matlab.

Definition at line 522 of file color_rgba.cpp.

References ColorRGBA(), inpclamp(), lass::num::NumTraits< C >::one, and lass::num::NumTraits< C >::zero.

const ColorRGBA lass::prim::ColorRGBA::mapSummer ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'summer' of matlab.

Definition at line 532 of file color_rgba.cpp.

References ColorRGBA(), inpclamp(), lass::num::NumTraits< C >::one, and lass::num::NumTraits< C >::zero.

const ColorRGBA lass::prim::ColorRGBA::mapWinter ( TParam  iValue  )  [static]

convert a value in range [0, 1] to a color like in colormap 'winter' of matlab.

Definition at line 542 of file color_rgba.cpp.

References ColorRGBA(), inpclamp(), lass::num::NumTraits< C >::one, and lass::num::NumTraits< C >::zero.

const ColorRGBA lass::prim::ColorRGBA::mapCustom ( TParam  iValue,
const std::vector< ColorRGBA > &  iColorMap 
) [static]

convert a value in range [0, 1] to a color from a custom color map.

Definition at line 552 of file color_rgba.cpp.

References doMap(), and LASS_ASSERT.

const ColorRGBA lass::prim::ColorRGBA::doMap ( TParam  iValue,
const ColorRGBA iMap,
int  iMapSize 
) [static, private]


Friends And Related Function Documentation

ColorRGBA operator+ ( const ColorRGBA iA,
const ColorRGBA iB 
) [related]

raw addition of iA and iB, including alpha channels

Definition at line 591 of file color_rgba.cpp.

ColorRGBA operator- ( const ColorRGBA iA,
const ColorRGBA iB 
) [related]

raw subtraction of iA and iB, including alpha channels

Definition at line 603 of file color_rgba.cpp.

ColorRGBA operator* ( const ColorRGBA iA,
const ColorRGBA iB 
) [related]

raw addition of iA and iB, including alpha channels

Definition at line 615 of file color_rgba.cpp.

ColorRGBA operator/ ( const ColorRGBA iA,
const ColorRGBA iB 
) [related]

raw addition of iA and iB, including alpha channels

Definition at line 627 of file color_rgba.cpp.

ColorRGBA operator+ ( ColorRGBA::TParam  iA,
const ColorRGBA iB 
) [related]

raw addition of iA and iB, including alpha channels

Definition at line 639 of file color_rgba.cpp.

ColorRGBA operator- ( ColorRGBA::TParam  iA,
const ColorRGBA iB 
) [related]

raw subtraction of iA and iB, including alpha channels

Definition at line 651 of file color_rgba.cpp.

ColorRGBA operator* ( ColorRGBA::TParam  iA,
const ColorRGBA iB 
) [related]

raw addition of iA and iB, including alpha channels

Definition at line 663 of file color_rgba.cpp.

ColorRGBA operator/ ( ColorRGBA::TParam  iA,
const ColorRGBA iB 
) [related]

raw addition of iA and iB, including alpha channels

Definition at line 675 of file color_rgba.cpp.

ColorRGBA operator+ ( const ColorRGBA iA,
ColorRGBA::TParam  iB 
) [related]

raw addition of iA and iB, including alpha channels

Definition at line 687 of file color_rgba.cpp.

ColorRGBA operator- ( const ColorRGBA iA,
ColorRGBA::TParam  iB 
) [related]

raw subtraction of iA and iB, including alpha channels

Definition at line 699 of file color_rgba.cpp.

ColorRGBA operator* ( const ColorRGBA iA,
ColorRGBA::TParam  iB 
) [related]

raw addition of iA and iB, including alpha channels

Definition at line 711 of file color_rgba.cpp.

ColorRGBA operator/ ( const ColorRGBA iA,
ColorRGBA::TParam  iB 
) [related]

raw addition of iA and iB, including alpha channels

Definition at line 723 of file color_rgba.cpp.


Field Documentation


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

Generated on Mon Nov 10 14:22:13 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo