Changeset 5011 in orxonox.OLD for orxonox/trunk/src/lib/util
- Timestamp:
- Aug 14, 2005, 3:58:22 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/util/color.cc
r5010 r5011 12 12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 15 this code has been borrowed from:16 http://www.easyrgb.com/math.php17 14 */ 18 15 … … 29 26 #include <stdio.h> 30 27 31 // Needed by rgb2hsv() 32 float Color::maxrgb(float r, float g, float b) 33 { 34 float max; 35 36 if( r > g) 37 max = r; 38 else 39 max = g; 40 if( b > max ) 41 max = b; 42 return( max ); 43 } 44 45 46 // Needed by rgb2hsv() 47 float Color::minrgb(float r,float g,float b) 48 { 49 float min; 50 51 if( r < g) 52 min = r; 53 else 54 min = g; 55 if( b < min ) 56 min = b; 57 return( min ); 58 } 59 60 61 /* Taken from "Fund'l of 3D Computer Graphics", Alan Watt (1989) 62 Assumes (r,g,b) range from 0.0 to 1.0 63 Sets h in degrees: 0.0 to 360.; 64 s,v in [0.,1.] 65 */ 28 /** 29 * transforms from RGB to HSVtoRGB 30 * @param RGB the RGB-color [0-1] 31 * @returns HSV: with values (h[0-360(degree)],s[0,1],v[0,1]) 32 */ 66 33 Vector Color::RGBtoHSV(const Vector& RGB) 67 34 { … … 99 66 else 100 67 printf("rgb2hsv::How did I get here?\n"); 101 h *= 60 ;68 h *= 60.; 102 69 if( h < 0) 103 70 h += 360.0; … … 106 73 } 107 74 108 /* Taken from "Fund'l of 3D Computer Graphics", Alan Watt (1989) 109 Assumes H in degrees, s,v in [0.,1.0]; 110 (r,g,b) range from 0.0 to 1.0 111 */ 75 /** 76 * converts a Color from HSV to RGBtoHSV 77 * @param HSV: Vector with values (h[0-360(degree)],s[0,1],v[0,1]) 78 * @returns RGB: Vector [0-1] 79 */ 112 80 Vector Color::HSVtoRGB(const Vector& HSV) 113 81 { … … 175 143 return Vector(r,g,b); 176 144 } 145 146 147 // Needed by rgb2hsv() 148 float Color::maxrgb(float r, float g, float b) 149 { 150 float max; 151 if( r > g) 152 max = r; 153 else 154 max = g; 155 if( b > max ) 156 max = b; 157 return( max ); 158 } 159 160 161 // Needed by rgb2hsv() 162 float Color::minrgb(float r,float g,float b) 163 { 164 float min; 165 166 if( r < g) 167 min = r; 168 else 169 min = g; 170 if( b < min ) 171 min = b; 172 return( min ); 173 } 174 -
orxonox/trunk/src/lib/util/color.h
r5010 r5011 13 13 class Vector; 14 14 15 //! a very abstract Class that helps transforming Colors into different Systems 15 16 class Color 16 17 {
Note: See TracChangeset
for help on using the changeset viewer.