Changeset 8986 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Jul 1, 2006, 4:57:07 PM (18 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/color.cc
r8619 r8986 20 20 21 21 22 //! Red Color 23 const Color Color::red(1,0,0, 1); 24 //! Green Color 25 const Color Color::green(0,1,0, 1) ; 26 //! blue Color 27 const Color Color::blue(0,0,1, 1); 28 //! White Color 29 const Color Color::white(1,1,1, 1); 30 //! Black Color 31 const Color Color::black(0,0,0,1); 32 //! Orx Color 33 const Color Color::orx(.2, .5, .7, .8); //!< TODO Define the ORX-color :) 34 35 36 void Color::slerpHSV(const Color& c, float v) 37 { 38 this->a() += (c.a() - this->a()) * v; 39 Vector from(r(), g(), b()); 40 Vector to(c.r(), c.g(), c.b()); 41 42 from = RGBtoHSV(from); 43 to = RGBtoHSV(to); 44 45 from += (to - from) * v; 46 47 to = HSVtoRGB(from); 48 49 this->r() = to.x; 50 this->g() = to.y; 51 this->b() = to.z; 52 } 53 54 Color Color::slerpHSVColor(const Color& from, const Color& to, float v) 55 { 56 Color fromColor(from); 57 fromColor.slerpHSV(to, v); 58 return fromColor; 59 } 60 61 22 62 void Color::debug() const 23 63 { … … 65 105 if( s == 0 ) 66 106 h = undefined; 67 else { 107 else 108 { 68 109 r_dist = (max_v - r)/diff; 69 110 g_dist = (max_v - g)/diff; … … 74 115 if( g == max_v ) 75 116 h = 2 + r_dist - b_dist; 76 else77 if( b == max_v )78 h = 4 + g_dist - r_dist;79 else80 printf("rgb2hsv::How did I get here?\n");117 else 118 if( b == max_v ) 119 h = 4 + g_dist - r_dist; 120 else 121 printf("rgb2hsv::How did I get here?\n"); 81 122 h *= 60.; 82 123 if( h < 0) … … 112 153 int i; 113 154 114 if( s == 0 ) { 155 if( s == 0 ) 156 { 115 157 r = v; 116 158 g = v; 117 159 b = v; 118 160 } 119 else { 120 if(h >= 360.) 121 h = h - (float)((int)(ceilf(h) / 360.0)); 161 else 162 { 163 if(h >= 360.) 164 h = h - (float)((int)(ceilf(h) / 360.0)); 122 165 h /= 60.; 123 166 i = (int) h; … … 126 169 q = v*(1-(s*f)); 127 170 t = v*(1-s*(1-f)); 128 switch(i) { 171 switch(i) 172 { 129 173 case 0: 130 174 r = v; … … 161 205 g = 1.0; 162 206 b = 1.0; 163 //printf("hsv2rgb::How did I get here?\n");164 // printf("h: %f, s: %f, v: %f; i: %d\n",hin,s,v,i);207 //printf("hsv2rgb::How did I get here?\n"); 208 // printf("h: %f, s: %f, v: %f; i: %d\n",hin,s,v,i); 165 209 break; 166 210 } -
trunk/src/lib/util/color.h
r8448 r8986 2 2 * @file color.h 3 3 * @brief Definition of color-calculations 4 * 5 * TODO CONVERT THE VECTORS to COLORS!! 4 6 * 5 7 * code borrowed from: … … 49 51 50 52 void slerp(const Color& c, float v) { *this += (c - *this) * v; }; 53 void slerpHSV(const Color& c, float v); 54 55 static Color slerpHSVColor(const Color& from, const Color& to, float v); 51 56 52 57 void debug() const; … … 63 68 static float maxrgb(float r, float g, float b); 64 69 70 public: 71 static const Color red; 72 static const Color green; 73 static const Color blue; 74 static const Color white; 75 static const Color black; 76 static const Color orx; 77 65 78 private: 66 79 float _rgba[4]; //!< Color Values
Note: See TracChangeset
for help on using the changeset viewer.