- Timestamp:
- Jul 1, 2006, 4:57:07 PM (18 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/gl/glgui_bar.h
r8984 r8986 31 31 void setRange(float minimum, float maximum); 32 32 33 float getValue() const { return this->_value; };34 float getMinimum() const { return this->_minimum; };35 float getMaximum() const { return this->_maximum; };33 float value() const { return this->_value; }; 34 float minimum() const { return this->_minimum; }; 35 float maximum() const { return this->_maximum; }; 36 36 37 37 virtual void update() { }; -
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 -
trunk/src/util/hud.cc
r8976 r8986 168 168 if (this->energyWidget != NULL) 169 169 { 170 this->energyWidget->setAbsCoor2D(0.0 * this->resX, 0. 9* this->resY);170 this->energyWidget->setAbsCoor2D(0.0 * this->resX, 0.85 * this->resY); 171 171 this->energyWidget->setWidgetSize(.25 * this->resX, 0.1 * this->resY); 172 172 } … … 177 177 for (weaponWidget = this->weaponsWidgets.begin(); weaponWidget != this->weaponsWidgets.end(); weaponWidget++, pos+=.3) 178 178 { 179 (*weaponWidget)->setAbsCoor2D(pos*this->resX, . 9*this->resY);179 (*weaponWidget)->setAbsCoor2D(pos*this->resX, .85*this->resY); 180 180 (*weaponWidget)->setWidgetSize(.02*this->resX, .1 *this->resY); 181 181 (*weaponWidget)->show(); -
trunk/src/world_entities/elements/glgui_energywidget.cc
r8985 r8986 40 40 this->_bar.setBackgroundColor(Color(0,0,0,0)); 41 41 this->_bar.setForegroundColor(Color(.5, .5, .5, 1)); 42 this->_bar.font().setBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);43 42 } 44 43 … … 70 69 71 70 this->_bar.setValue(value); 72 this->_bar.setForegroundColor(Color (1 - (value / this->_bar.getMaximum()), value / this->_bar.getMaximum(),0,1));71 this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum())); 73 72 this->_bar.setFrontColor(Color(1,1,1,1), true); 74 73 this->_valueText.setText(val.getString());
Note: See TracChangeset
for help on using the changeset viewer.