29 #include <boost/lexical_cast.hpp>
31 #include "../common/exceptions/WOutOfBounds.h"
32 #include "../common/WStringUtils.h"
63 WColor convertHSVtoRGBA(
double h,
double s,
double v )
65 const double onethird = 1.0 / 3.0;
66 const double onesixth = 1.0 / 6.0;
67 const double twothird = 2.0 / 3.0;
68 const double fivesixth = 5.0 / 6.0;
74 if( h > onesixth && h <= onethird )
77 r = ( onethird - h ) / onesixth;
80 else if( h > onethird && h <= 0.5 )
83 b = ( h - onethird ) / onesixth;
86 else if( h > 0.5 && h <= twothird )
89 g = ( twothird - h ) / onesixth;
92 else if( h > twothird && h <= fivesixth )
95 r = ( h - twothird ) / onesixth;
98 else if( h > fivesixth && h <= 1.0)
101 b = ( 1.0 - h ) / onesixth;
112 r = ( s * r + ( 1.0 - s ) ) * v;
113 g = ( s * g + ( 1.0 - s ) ) * v;
114 b = ( s * b + ( 1.0 - s ) ) * v;
116 return WColor( r, g, b, 1.0f );
119 WColor inverseColor(
const WColor& other )
121 return WColor( std::abs( 1.0f - other[0] ), std::abs( 1.0f - other[1] ), std::abs( 1.0f - other[2] ), other[3] );