#include <OSGColor.h>
Public Types | |
| typedef ValueTypeT | ValueType |
Public Member Functions | |
Constructors | |
| * | Color3 (void) |
| Color3 (const Color3 &source) | |
| Color3 (ValueType red, ValueType green, ValueType blue) | |
Destructors | |
| * | ~Color3 (void) |
Set | |
| *void | clear (void) |
| void | setValuesRGB (const ValueType red, const ValueType green, const ValueType blue) |
| void | setValuesHSV (const Real32 h, const Real32 s, const Real32 v) |
| void | setRandom (void) |
| void | setRGB (UInt32 rgbPack) |
| void | setValue (const Char8 *szString) |
| void | setValue (Char8 *szString) |
Get | |
| *UInt32 | getRGB (void) const |
| void | getValuesRGB (ValueType &red, ValueType &green, ValueType &blue) const |
| void | getValuesHSV (Real32 &h, Real32 &s, Real32 &v) const |
| ValueType | red (void) const |
| ValueType | green (void) const |
| ValueType | blue (void) const |
| ValueType * | getValuesRGB (void) |
| const ValueType * | getValuesRGB (void) const |
Operators | |
| *Color3 | operator * (const ValueType val) |
| ValueType & | operator[] (const UInt32 uiIndex) |
| const ValueType & | operator[] (const UInt32 uiIndex) const |
| Color3 & | operator= (const Color3 &source) |
| bool | equals (const Color3 &other, const ValueType tolerance) const |
| bool | operator== (const Color3 &other) const |
| bool | operator!= (const Color3 &other) const |
Static Public Member Functions | |
Class Specific | |
| *static void | convertFromHSV (ValueType *rgbP, const Real32 h, const Real32 s, const Real32 v) |
| static void | convertToHSV (const ValueType *rgbP, Real32 &h, Real32 &s, Real32 &v) |
| static UInt32 | minPart (const ValueType *rgbP) |
| static UInt32 | maxPart (const ValueType *rgbP) |
Static Public Attributes | |
| static const Color3 | Null |
Protected Attributes | |
| ValueType | _rgb [3] |
Definition at line 55 of file OSGColor.h.
|
|||||
|
Definition at line 61 of file OSGColor.h. |
|
||||||||||
|
Definition at line 240 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00241 { 00242 _rgb[0] = TypeTraits<ValueTypeT>::getZeroElement(); 00243 _rgb[1] = TypeTraits<ValueTypeT>::getZeroElement(); 00244 _rgb[2] = TypeTraits<ValueTypeT>::getZeroElement(); 00245 }
|
|
||||||||||
|
Definition at line 249 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00250 { 00251 _rgb[0] = source._rgb[0]; 00252 _rgb[1] = source._rgb[1]; 00253 _rgb[2] = source._rgb[2]; 00254 }
|
|
||||||||||||||||||||
|
Definition at line 258 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb.
|
|
||||||||||
|
Definition at line 269 of file OSGColor.inl.
|
|
||||||||||||||||||||||||
|
Definition at line 60 of file OSGColor.inl. References p. Referenced by osg::Color3< ValueTypeT >::setValuesHSV(). 00064 { 00065 if(rgbP == NULL) 00066 return; 00067 00068 Int32 i; 00069 Real32 f; 00070 Real32 p; 00071 Real32 q; 00072 Real32 t; 00073 00074 if(s) 00075 { 00076 f = (h == 360) ? 0.0 : (h / 60.0); 00077 i = Int32(f); 00078 00079 f = f - Real32(i); 00080 00081 p = v * (1.0 - s ); 00082 q = v * (1.0 - (s * f) ); 00083 t = v * (1.0 - (s * (1 - f))); 00084 00085 switch (i) 00086 { 00087 case 0: 00088 rgbP[0] = TypeTraits<ValueTypeT>::getPortion(v); 00089 rgbP[1] = TypeTraits<ValueTypeT>::getPortion(t); 00090 rgbP[2] = TypeTraits<ValueTypeT>::getPortion(p); 00091 break; 00092 case 1: 00093 rgbP[0] = TypeTraits<ValueTypeT>::getPortion(q); 00094 rgbP[1] = TypeTraits<ValueTypeT>::getPortion(v); 00095 rgbP[2] = TypeTraits<ValueTypeT>::getPortion(p); 00096 break; 00097 case 2: 00098 rgbP[0] = TypeTraits<ValueTypeT>::getPortion(p); 00099 rgbP[1] = TypeTraits<ValueTypeT>::getPortion(v); 00100 rgbP[2] = TypeTraits<ValueTypeT>::getPortion(t); 00101 break; 00102 case 3: 00103 rgbP[0] = TypeTraits<ValueTypeT>::getPortion(p); 00104 rgbP[1] = TypeTraits<ValueTypeT>::getPortion(q); 00105 rgbP[2] = TypeTraits<ValueTypeT>::getPortion(v); 00106 break; 00107 case 4: 00108 rgbP[0] = TypeTraits<ValueTypeT>::getPortion(t); 00109 rgbP[1] = TypeTraits<ValueTypeT>::getPortion(p); 00110 rgbP[2] = TypeTraits<ValueTypeT>::getPortion(v); 00111 break; 00112 case 5: 00113 rgbP[0] = TypeTraits<ValueTypeT>::getPortion(v); 00114 rgbP[1] = TypeTraits<ValueTypeT>::getPortion(p); 00115 rgbP[2] = TypeTraits<ValueTypeT>::getPortion(q); 00116 break; 00117 default: 00118 std::cerr << "ERROR i not in [0, 5] in Color::setHSV()!" 00119 << std::endl; 00120 break; 00121 } 00122 } 00123 else 00124 { 00125 rgbP[0] = rgbP[1] = rgbP[2] = 00126 TypeTraits<ValueTypeT>::getPortion(v); 00127 } 00128 }
|
|
||||||||||||||||||||||||
|
Definition at line 132 of file OSGColor.inl. References osg::Color3< ValueTypeT >::maxPart(), and osg::Color3< ValueTypeT >::minPart(). Referenced by osg::Color3< ValueTypeT >::getValuesHSV(). 00136 { 00137 if(rgbP == NULL) 00138 return; 00139 00140 const Real32 r = TypeTraits<ValueTypeT>::getFraction(rgbP[0]); 00141 const Real32 g = TypeTraits<ValueTypeT>::getFraction(rgbP[1]); 00142 const Real32 b = TypeTraits<ValueTypeT>::getFraction(rgbP[2]); 00143 00144 const Int32 maxIndex = maxPart(rgbP); 00145 const Int32 minIndex = minPart(rgbP); 00146 00147 const Real32 max = TypeTraits<ValueTypeT>::getFraction( 00148 rgbP[maxIndex]); 00149 00150 const Real32 min = TypeTraits<ValueTypeT>::getFraction( 00151 rgbP[minIndex]); 00152 00153 const Real32 delta = max - min; 00154 00155 v = max; 00156 s = max ? (max - min) / max : 0.0; 00157 00158 if(s) 00159 { 00160 switch(maxIndex) 00161 { 00162 case 0: // red part is max; 00163 h = (( g - b) / delta) * 60.0; 00164 break; 00165 case 1: // green part is max; 00166 h = (2.0 + (( b - r) / delta)) * 60.0; 00167 break; 00168 case 2: // blue part is max 00169 h = (4.0 + (( r - g) / delta)) * 60.0; 00170 break; 00171 } 00172 00173 if(h < 0.0) 00174 h += 360.0; 00175 } 00176 else 00177 { 00178 h = 0.0; 00179 } 00180 }
|
|
||||||||||
|
Definition at line 212 of file OSGColor.inl. Referenced by osg::Color3< ValueTypeT >::convertToHSV(). 00213 { 00214 if(rgbP[0] < rgbP[1]) 00215 { 00216 if(rgbP[2] < rgbP[0]) 00217 { 00218 return 2; 00219 } 00220 else 00221 { 00222 return 0; 00223 } 00224 } 00225 else 00226 { 00227 if(rgbP[2] < rgbP[1]) 00228 { 00229 return 2; 00230 } 00231 else 00232 { 00233 return 1; 00234 } 00235 } 00236 }
|
|
||||||||||
|
Definition at line 184 of file OSGColor.inl. Referenced by osg::Color3< ValueTypeT >::convertToHSV(). 00185 { 00186 if(rgbP[0] > rgbP[1]) 00187 { 00188 if(rgbP[2] > rgbP[0]) 00189 { 00190 return 2; 00191 } 00192 else 00193 { 00194 return 0; 00195 } 00196 } 00197 else 00198 { 00199 if (rgbP[2] > rgbP[1]) 00200 { 00201 return 2; 00202 } 00203 else 00204 { 00205 return 1; 00206 } 00207 } 00208 }
|
|
||||||||||
|
Definition at line 275 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00276 { 00277 _rgb[0] = TypeTraits<ValueTypeT>::getZeroElement(); 00278 _rgb[1] = TypeTraits<ValueTypeT>::getZeroElement(); 00279 _rgb[2] = TypeTraits<ValueTypeT>::getZeroElement(); 00280 }
|
|
||||||||||||||||||||
|
Definition at line 284 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. Referenced by osg::ProxyGroup::draw(), osg::RenderAction::pushVisibility(), osg::DrawActionBase::selectVisibles(), and osg::Color3< ValueTypeT >::setRandom().
|
|
||||||||||||||||||||
|
Definition at line 295 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb, and osg::Color3< ValueTypeT >::convertFromHSV(). 00298 { 00299 convertFromHSV(_rgb, h, s, v); 00300 }
|
|
||||||||||
|
Definition at line 304 of file OSGColor.inl. References osg::Color3< ValueTypeT >::setValuesRGB(). 00305 { 00306 Real32 rf = 1.0 / Real32(RAND_MAX); 00307 00308 setValuesRGB(TypeTraits<ValueTypeT>::getPortion(rf * rand()), 00309 TypeTraits<ValueTypeT>::getPortion(rf * rand()), 00310 TypeTraits<ValueTypeT>::getPortion(rf * rand())); 00311 }
|
|
||||||||||
|
method to set the rgb values (BBGGRR) Definition at line 317 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00318 { 00319 for(Int32 i = 0; i < 3; ++i) 00320 { 00321 Real32 rTmp = Real32(rgbPack & 255) / 255.0f; 00322 00323 _rgb[i] = TypeTraits<ValueTypeT>::getPortion(rTmp); 00324 00325 rgbPack >>= 8; 00326 } 00327 }
|
|
||||||||||
|
Definition at line 331 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb, and osg::PointInterface< ValueTypeT, StorageInterfaceT >::setValueFromCString(). Referenced by osg::FieldDataTraits< Color3ub >::getFromString(), osg::FieldDataTraits< Color3f >::getFromString(), osg::ClusterWindow::loadCalibration(), and osg::Color3< ValueTypeT >::setValue(). 00332 { 00333 // this is the easiest way, not the most efficient... 00334 00335 Vec3f v; 00336 00337 v.setValueFromCString(szString); 00338 00339 _rgb[0] = ValueTypeT(v[0]); 00340 _rgb[1] = ValueTypeT(v[1]); 00341 _rgb[2] = ValueTypeT(v[2]); 00342 }
|
|
||||||||||
|
Definition at line 346 of file OSGColor.inl. References osg::Color3< ValueTypeT >::setValue(). 00347 { 00348 setValue(static_cast<const Char8 *>(szString)); 00349 }
|
|
||||||||||
|
method to get a packed rgb value (BBGGRR) Definition at line 356 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00357 { 00358 UInt32 pack = 0; 00359 00360 for(Int32 i = 2; i >= 0; --i) 00361 { 00362 pack = (pack << 8) | 00363 Int32(TypeTraits<ValueTypeT>::getFraction(_rgb[i]) * 00364 255.0f + 00365 0.5f ); 00366 } 00367 00368 return pack; 00369 }
|
|
||||||||||||||||||||
|
method to get a packed rgb value (BBGGRR) Definition at line 373 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. Referenced by osg::GradientBackground::clear(), and VolumeDrawWrapper::draw().
|
|
||||||||||||||||||||
|
method to get a packed rgb value (BBGGRR) Definition at line 384 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb, and osg::Color3< ValueTypeT >::convertToHSV(). 00387 { 00388 convertToHSV(_rgb, h, s, v); 00389 }
|
|
||||||||||
|
method to get a packed rgb value (BBGGRR) Definition at line 394 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. Referenced by osg::operator<<(), osg::FieldDataTraits< Color3ub >::putToString(), and osg::FieldDataTraits< Color3f >::putToString(). 00395 { 00396 return _rgb[0]; 00397 }
|
|
||||||||||
|
method to get a packed rgb value (BBGGRR) Definition at line 401 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. Referenced by osg::operator<<(), osg::FieldDataTraits< Color3ub >::putToString(), and osg::FieldDataTraits< Color3f >::putToString(). 00402 { 00403 return _rgb[1]; 00404 }
|
|
||||||||||
|
method to get a packed rgb value (BBGGRR) Definition at line 408 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. Referenced by osg::operator<<(), osg::FieldDataTraits< Color3ub >::putToString(), and osg::FieldDataTraits< Color3f >::putToString(). 00409 { 00410 return _rgb[2]; 00411 }
|
|
||||||||||
|
method to get a packed rgb value (BBGGRR) Definition at line 416 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00417 { 00418 return _rgb; 00419 }
|
|
||||||||||
|
method to get a packed rgb value (BBGGRR) Definition at line 423 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00424 { 00425 return _rgb; 00426 }
|
|
||||||||||
|
Definition at line 430 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00431 { 00432 Color3<ValueTypeT> returnValue; 00433 00434 returnValue._rgb[0] = _rgb[0] * val; 00435 returnValue._rgb[1] = _rgb[1] * val; 00436 returnValue._rgb[2] = _rgb[2] * val; 00437 00438 return returnValue; 00439 }
|
|
||||||||||
|
Definition at line 443 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00445 { 00446 return _rgb[uiIndex]; 00447 }
|
|
||||||||||
|
Definition at line 451 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00453 { 00454 return _rgb[uiIndex]; 00455 }
|
|
||||||||||
|
Definition at line 459 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00460 { 00461 if (this == &other) 00462 return *this; 00463 00464 _rgb[0] = other._rgb[0]; 00465 _rgb[1] = other._rgb[1]; 00466 _rgb[2] = other._rgb[2]; 00467 00468 return *this; 00469 }
|
|
||||||||||||||||
|
Definition at line 473 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb. 00475 { 00476 bool returnValue = true; 00477 00478 for(UInt32 i = 0; i < 3; i++) 00479 { 00480 returnValue &= ( ( _rgb[i] - other._rgb[i] <= tolerance) && 00481 (other._rgb[i] - _rgb[i] <= tolerance)); 00482 } 00483 00484 return returnValue; 00485 }
|
|
||||||||||
|
Definition at line 489 of file OSGColor.inl. References osg::Color3< ValueTypeT >::_rgb, and osg::Eps. 00490 { 00491 bool returnValue = true; 00492 00493 for(UInt32 i = 0; i < 3; i++) 00494 { 00495 returnValue &= ( ( _rgb[i] - other._rgb[i] <= Eps) && 00496 (other._rgb[i] - _rgb[i] <= Eps)); 00497 } 00498 00499 return returnValue; 00500 }
|
|
||||||||||
|
Definition at line 504 of file OSGColor.inl.
|
|
|||||
|
Definition at line 56 of file OSGColor.inl. |
|
|||||
1.4.3