30 #include "../common/exceptions/WOutOfBounds.h"
31 #include "../common/WStringUtils.h"
35 namespace defaultColor
40 RED, GREEN, BLUE, YELLOW, ORANGE, PINK, CYAN,
42 LIGHTRED, LIGHTGREEN, LIGHTBLUE, LIGHTYELLOW,
44 DARKRED, DARKGREEN, DARKBLUE, DARKYELLOW, VIOLET, TEAL,
46 BLACK, GRAY25, GRAY50, GRAY75, WHITE
78 WColor convertHSVtoRGBA(
double h,
double s,
double v )
80 const double onethird = 1.0 / 3.0;
81 const double onesixth = 1.0 / 6.0;
82 const double twothird = 2.0 / 3.0;
83 const double fivesixth = 5.0 / 6.0;
89 if( h > onesixth && h <= onethird )
92 r = ( onethird - h ) / onesixth;
95 else if( h > onethird && h <= 0.5 )
98 b = ( h - onethird ) / onesixth;
101 else if( h > 0.5 && h <= twothird )
104 g = ( twothird - h ) / onesixth;
107 else if( h > twothird && h <= fivesixth )
110 r = ( h - twothird ) / onesixth;
113 else if( h > fivesixth && h <= 1.0)
116 b = ( 1.0 - h ) / onesixth;
127 r = ( s * r + ( 1.0 - s ) ) * v;
128 g = ( s * g + ( 1.0 - s ) ) * v;
129 b = ( s * b + ( 1.0 - s ) ) * v;
131 return WColor( r, g, b, 1.0f );
134 WColor inverseColor(
const WColor& other )
136 return WColor( std::abs( 1.0f - other[0] ), std::abs( 1.0f - other[1] ), std::abs( 1.0f - other[2] ), other[3] );