color_rgba.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_COLOR_RGBA_H
00051 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_COLOR_RGBA_H
00052
00053 #include "prim_common.h"
00054 #include "vector_4d.h"
00055
00056 namespace lass
00057 {
00058 namespace prim
00059 {
00060
00061 class LASS_DLL ColorRGBA
00062 {
00063 public:
00064
00065 typedef Vector4D<float> TVector;
00066
00067 typedef TVector::TValue TValue;
00068 typedef TVector::TParam TParam;
00069 typedef TVector::TReference TReference;
00070 typedef TVector::TConstReference TConstReference;
00071 typedef TVector::TNumTraits TNumTraits;
00072
00073 enum { dimension = 4 };
00074
00075 TValue r;
00076 TValue g;
00077 TValue b;
00078 TValue a;
00079
00080 ColorRGBA();
00081 ColorRGBA(TParam iRed, TParam iGreen, TParam iBlue,
00082 TParam iAlpha = ColorRGBA::TNumTraits::one);
00083 explicit ColorRGBA(TParam iWhite, TParam iAlpha = ColorRGBA::TNumTraits::one);
00084 explicit ColorRGBA(const TVector& iVector);
00085
00086
00087
00088 const TVector vector() const { return TVector(r, g, b, a); }
00089 TConstReference operator[](unsigned iIndex) const { return *(&r + iIndex); }
00090 TReference operator[](unsigned iIndex) { return *(&r + iIndex); }
00091 TConstReference at(signed iIndex) const { return *(&r + num::mod(iIndex, static_cast<unsigned>(dimension))); }
00092 TReference at(signed iIndex) { return *(&r + num::mod(iIndex, static_cast<unsigned>(dimension))); }
00093
00094 const ColorRGBA& operator+() const;
00095 const ColorRGBA operator-() const;
00096 ColorRGBA& operator+=( const ColorRGBA& iOther );
00097 ColorRGBA& operator-=( const ColorRGBA& iOther );
00098 ColorRGBA& operator*=( const ColorRGBA& iOther );
00099 ColorRGBA& operator/=( const ColorRGBA& iOther );
00100 ColorRGBA& operator+=( TParam iWhite );
00101 ColorRGBA& operator-=( TParam iWhite );
00102 ColorRGBA& operator*=( TParam iWhite );
00103 ColorRGBA& operator/=( TParam iWhite );
00104
00105 const TValue brightness() const;
00106 const bool isBlack() const;
00107 const bool isZero() const;
00108 const bool isNaN() const;
00109
00110 const ColorRGBA darkened( TParam iFactor ) const;
00111 const ColorRGBA dissolved( TParam iFactor) const;
00112 const ColorRGBA gammaCorrected(TParam iGamma) const;
00113 const ColorRGBA exposed(TParam iTime) const;
00114 const ColorRGBA invExposed(TParam iTime) const;
00115 const ColorRGBA clamped() const;
00116
00117
00118
00119 static const ColorRGBA mapAutumn(TParam iValue);
00120 static const ColorRGBA mapBone(TParam iValue);
00121 static const ColorRGBA mapCool(TParam iValue);
00122 static const ColorRGBA mapCopper(TParam iValue);
00123 static const ColorRGBA mapGray(TParam iValue);
00124 static const ColorRGBA mapHot(TParam iValue);
00125 static const ColorRGBA mapHsv(TParam iValue);
00126 static const ColorRGBA mapJet(TParam iValue);
00127 static const ColorRGBA mapPink(TParam iValue);
00128 static const ColorRGBA mapSpring(TParam iValue);
00129 static const ColorRGBA mapSummer(TParam iValue);
00130 static const ColorRGBA mapWinter(TParam iValue);
00131 static const ColorRGBA mapCustom(TParam iValue, const std::vector<ColorRGBA>& iColorMap);
00132 private:
00133
00134 static const ColorRGBA doMap(TParam iValue, const ColorRGBA* iMap, int iMapSize);
00135 };
00136
00137 LASS_DLL ColorRGBA LASS_CALL operator+( const ColorRGBA& iA, const ColorRGBA& iB );
00138 LASS_DLL ColorRGBA LASS_CALL operator-( const ColorRGBA& iA, const ColorRGBA& iB );
00139 LASS_DLL ColorRGBA LASS_CALL operator*( const ColorRGBA& iA, const ColorRGBA& iB );
00140 LASS_DLL ColorRGBA LASS_CALL operator/( const ColorRGBA& iA, const ColorRGBA& iB );
00141 LASS_DLL ColorRGBA LASS_CALL operator+( ColorRGBA::TParam iA, const ColorRGBA& iB );
00142 LASS_DLL ColorRGBA LASS_CALL operator-( ColorRGBA::TParam iA, const ColorRGBA& iB );
00143 LASS_DLL ColorRGBA LASS_CALL operator*( ColorRGBA::TParam iA, const ColorRGBA& iB );
00144 LASS_DLL ColorRGBA LASS_CALL operator/( ColorRGBA::TParam iA, const ColorRGBA& iB );
00145 LASS_DLL ColorRGBA LASS_CALL operator+( const ColorRGBA& iA, ColorRGBA::TParam iB );
00146 LASS_DLL ColorRGBA LASS_CALL operator-( const ColorRGBA& iA, ColorRGBA::TParam iB );
00147 LASS_DLL ColorRGBA LASS_CALL operator*( const ColorRGBA& iA, ColorRGBA::TParam iB );
00148 LASS_DLL ColorRGBA LASS_CALL operator/( const ColorRGBA& iA, ColorRGBA::TParam iB );
00149
00150 LASS_DLL ColorRGBA LASS_CALL over( const ColorRGBA& iA, const ColorRGBA& iB );
00151 LASS_DLL ColorRGBA LASS_CALL in( const ColorRGBA& iA, const ColorRGBA& iB );
00152 LASS_DLL ColorRGBA LASS_CALL out( const ColorRGBA& iA, const ColorRGBA& iB );
00153 LASS_DLL ColorRGBA LASS_CALL atop( const ColorRGBA& iA, const ColorRGBA& iB );
00154 LASS_DLL ColorRGBA LASS_CALL plus( const ColorRGBA& iA, const ColorRGBA& iB );
00155 LASS_DLL ColorRGBA LASS_CALL through( const ColorRGBA& iA, const ColorRGBA& iB );
00156
00157 LASS_DLL ColorRGBA::TValue LASS_CALL distance( const ColorRGBA& iA, const ColorRGBA& iB );
00158
00159 }
00160
00161 }
00162
00163 #define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_COLOR_RGBA
00164 #ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_PLUS_H
00165 # include "pyobject_util.h"
00166 #endif
00167
00168 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_TRANSFORMATION_3D_H
00169 # include "color_rgba_transformation_3d.h"
00170 #endif
00171
00172 #endif
00173
00174