49#if LASS_COMPILER_TYPE == LASS_COMPILER_TYPE_MSVC
50# pragma warning(disable: 4305 4244)
206 const TValue invWhite = TNumTraits::one / white;
216ColorRGBA::TValue ColorRGBA::brightness()
const
218 return (r + g + b) / 3;
227 return r == TNumTraits::zero && g == TNumTraits::zero && b == TNumTraits::zero;
236 return r == TNumTraits::zero && g == TNumTraits::zero && b == TNumTraits::zero &&
237 a == TNumTraits::zero;
246 return num::isNaN(r) || num::isNaN(g) || num::isNaN(b) || num::isNaN(a);
305 const TValue invGamma =
num::inv(gammaExponent);
325 const TValue f = -exposureTime;
327 num::clamp(TNumTraits::one - num::exp(f * r), TNumTraits::zero, TNumTraits::one),
328 num::clamp(TNumTraits::one - num::exp(f * g), TNumTraits::zero, TNumTraits::one),
329 num::clamp(TNumTraits::one - num::exp(f * b), TNumTraits::zero, TNumTraits::one),
330 num::clamp(a, TNumTraits::zero, TNumTraits::one));
349 const TValue f =
num::inv(-exposureTime);
351 f * num::log(
num::clamp(TNumTraits::one - r, TNumTraits::minStrictPositive, TNumTraits::one)),
352 f * num::log(
num::clamp(TNumTraits::one - g, TNumTraits::minStrictPositive, TNumTraits::one)),
353 f * num::log(
num::clamp(TNumTraits::one - b, TNumTraits::minStrictPositive, TNumTraits::one)),
365 num::clamp(r, TNumTraits::zero, TNumTraits::one),
366 num::clamp(g, TNumTraits::zero, TNumTraits::one),
367 num::clamp(b, TNumTraits::zero, TNumTraits::one),
368 num::clamp(a, TNumTraits::zero, TNumTraits::one));
377 num::inpclamp(value, TNumTraits::zero, TNumTraits::one);
378 return ColorRGBA(TNumTraits::one, value, TNumTraits::zero);
394 return doMap(value, keys, 4);
403 num::inpclamp(value, TNumTraits::zero, TNumTraits::one);
404 return ColorRGBA(value, TNumTraits::one - value, TNumTraits::one);
413 num::inpclamp(value, TNumTraits::zero, TNumTraits::one);
414 return ColorRGBA(value < .8f ? value / .8f : 1.f, .8f * value, .5f * value);
423 num::inpclamp(value, TNumTraits::zero, TNumTraits::one);
445 return doMap(value, keys, 9);
464 return doMap(value - num::floor(value), keys, 7);
486 return doMap(value, keys, 9);
515 return doMap(value, keys, 17);
524 num::inpclamp(value, TNumTraits::zero, TNumTraits::one);
525 return ColorRGBA(TNumTraits::one, value, TNumTraits::one - value);
534 num::inpclamp(value, TNumTraits::zero, TNumTraits::one);
535 return ColorRGBA(value, (TNumTraits::one + value) / 2, 0.4f * TNumTraits::one);
544 num::inpclamp(value, TNumTraits::zero, TNumTraits::one);
545 return ColorRGBA(0, TNumTraits::one - value, TNumTraits::one / 2);
554 LASS_ASSERT(
static_cast<int>(iColorMap.size()) >= 0);
555 return doMap(value, &iColorMap[0],
static_cast<int>(iColorMap.size()));
568 LASS_ASSERT(mapSize > 1);
570 num::inpclamp(value, TNumTraits::zero, TNumTraits::one);
571 const TValue x = value *
static_cast<TValue
>(mapSize - 1);
572 const TValue x0 = num::floor(x);
574 const int i =
static_cast<int>(x0);
575 LASS_ASSERT(i >= 0 && i < mapSize);
577 if (i == mapSize - 1)
582 const TValue dx = x - x0;
583 return map[i] * (TNumTraits::one - dx) + map[i + 1] * dx;
749 const ColorRGBA::TValue unfilteredB = (ColorRGBA::TNumTraits::one - a.a) * b.a;
750 const ColorRGBA::TValue alphaR = a.a + unfilteredB;
752 result *= unfilteredB;
803 result.a *= (ColorRGBA::TNumTraits::one - b.a);
828 result += b * (ColorRGBA::TNumTraits::one - a.a);
851 result.a = a.a + b.a;
871 result += a * (ColorRGBA::TNumTraits::one - a.b);
an [0, 1] floating point RGB colour with Alpha channel.
ColorRGBA operator-(const ColorRGBA &a, ColorRGBA::TParam b)
raw subtraction of a and b, including alpha channels
ColorRGBA operator*(ColorRGBA::TParam a, const ColorRGBA &b)
raw addition of a and b, including alpha channels
ColorRGBA & operator-=(const ColorRGBA &other)
raw subtraction other from this color, including alpha channel
static const ColorRGBA mapWinter(TParam value)
convert a value in range [0, 1] to a color like in colormap 'winter' of matlab.
static const ColorRGBA mapHot(TParam value)
convert a value in range [0, 1] to a color like in colormap 'hot' of matlab.
static const ColorRGBA mapPink(TParam value)
convert a value in range [0, 1] to a color like in colormap 'pink' of matlab.
ColorRGBA operator/(const ColorRGBA &a, const ColorRGBA &b)
raw addition of a and b, including alpha channels
ColorRGBA operator/(const ColorRGBA &a, ColorRGBA::TParam b)
raw addition of a and b, including alpha channels
const ColorRGBA darkened(TParam factor) const
return darkened colour without changing the opaqueness.
static const ColorRGBA mapCopper(TParam value)
convert a value in range [0, 1] to a color like in colormap 'copper' of matlab.
bool isBlack() const
return true if all color components are zero
static const ColorRGBA mapCool(TParam value)
convert a value in range [0, 1] to a color like in colormap 'cool' of matlab.
const ColorRGBA exposed(TParam time) const
return exposed color.
static const ColorRGBA mapBone(TParam value)
convert a value in range [0, 1] to a color like in colormap 'bone' of matlab.
ColorRGBA operator-(const ColorRGBA &a, const ColorRGBA &b)
raw subtraction of a and b, including alpha channels
ColorRGBA operator+(ColorRGBA::TParam a, const ColorRGBA &b)
raw addition of a and b, including alpha channels
static const ColorRGBA mapJet(TParam value)
convert a value in range [0, 1] to a color like in colormap 'jet' of matlab.
static const ColorRGBA mapAutumn(TParam value)
convert a value in range [0, 1] to a color like in colormap 'autumn' of matlab.
ColorRGBA()
construct an unexisting color (black with zero alpha)
bool isNaN() const
Return true if at least one of the components is NaN.
ColorRGBA operator+(const ColorRGBA &a, const ColorRGBA &b)
raw addition of a and b, including alpha channels
const ColorRGBA invExposed(TParam time) const
return result of inverse exposure function
static const ColorRGBA mapGray(TParam value)
convert a value in range [0, 1] to a color like in colormap 'gray' of matlab.
static const ColorRGBA mapSummer(TParam value)
convert a value in range [0, 1] to a color like in colormap 'summer' of matlab.
const ColorRGBA clamped() const
clamp all channels (including alpha channel) to the range [0, 1].
ColorRGBA & operator*=(const ColorRGBA &other)
raw multiplication of other with this color, including alpha channel
ColorRGBA operator-(ColorRGBA::TParam a, const ColorRGBA &b)
raw subtraction of a and b, including alpha channels
const ColorRGBA gammaCorrected(TParam gamma) const
return gamma corrected color.
static const ColorRGBA mapCustom(TParam value, const std::vector< ColorRGBA > &colorMap)
convert a value in range [0, 1] to a color from a custom color map.
ColorRGBA operator/(ColorRGBA::TParam a, const ColorRGBA &b)
raw addition of a and b, including alpha channels
const ColorRGBA dissolved(TParam factor) const
return color with dissolved opaqueness
ColorRGBA operator*(const ColorRGBA &a, ColorRGBA::TParam b)
raw addition of a and b, including alpha channels
ColorRGBA & operator+=(const ColorRGBA &other)
raw addition of other to this color, including alpha channel
static const ColorRGBA mapHsv(TParam value)
convert a value to a color like in colormap 'hsv' of matlab.
ColorRGBA & operator/=(const ColorRGBA &other)
raw division of this color by other, including alpha channel
ColorRGBA operator*(const ColorRGBA &a, const ColorRGBA &b)
raw addition of a and b, including alpha channels
static const ColorRGBA mapSpring(TParam value)
convert a value in range [0, 1] to a color like in colormap 'spring' of matlab.
bool isZero() const
return true if all components are zero
ColorRGBA operator+(const ColorRGBA &a, ColorRGBA::TParam b)
raw addition of a and b, including alpha channels
T sqr(const T &x)
return x * x
T inv(const T &x)
return x ^ -1
const T & clamp(const T &x, const T &min, const T &max)
if x < min return min, else if x > max return max, else return x.
T pow(const T &x, const T &p)
return exp(p * log(x));
set of geometrical primitives
ColorRGBA plus(const ColorRGBA &a, const ColorRGBA &b)
ColorRGBA over(const ColorRGBA &a, const ColorRGBA &b)
placement of foreground a in front of background b.
ColorRGBA out(const ColorRGBA &a, const ColorRGBA &b)
a held out by b, part of a outside b.
ColorRGBA through(const ColorRGBA &a, const ColorRGBA &b)
a seen through color filter b.
ColorRGBA in(const ColorRGBA &a, const ColorRGBA &b)
part of a inside b.
ColorRGBA atop(const ColorRGBA &a, const ColorRGBA &b)
union of a in b and b out a.
Library for Assembled Shared Sources.