23#include <rtl/math.hxx>
30 const double minVal = std::min( std::min( r, g ), b );
31 const double maxVal = std::max( std::max( r, g ), b );
32 const double d = maxVal - minVal;
36 l = (maxVal + minVal) / 2.0;
44 s = l > 0.5 ?
d/(2.0-maxVal-minVal) :
47 if( rtl::math::approxEqual(r, maxVal) )
49 else if( rtl::math::approxEqual(g, maxVal) )
63 static double hsl2rgbHelper(
double nValue1,
double nValue2,
double nHue )
66 nHue = fmod( nHue, 360.0 );
73 return nValue1 + (nValue2 - nValue1)*nHue/60.0;
74 else if( nHue < 180.0 )
76 else if( nHue < 240.0 )
77 return nValue1 + (nValue2 - nValue1)*(240.0 - nHue)/60.0;
89 const double nVal1( l <= 0.5 ? l*(1.0 + s) : l + s - l*s );
90 const double nVal2( 2.0*l - nVal1 );
107 const double maxVal = std::max(std::max(r,g),b);
108 const double minVal = std::min(std::min(r,g),b);
109 const double delta = maxVal-minVal;
111 double h=0, s=0,
v=0;
121 if( rtl::math::approxEqual(maxVal, r) )
125 else if( rtl::math::approxEqual(maxVal, g) )
127 h = 2.0 + (b - r) / delta;
131 h = 4.0 + (r - g) / delta;
159 const sal_Int32 intval =
static_cast< sal_Int32
>(
h );
160 const double f =
h - intval;
161 const double p =
v*(1.0-s);
162 const double q =
v*(1.0-(s*f));
163 const double t =
v*(1.0-(s*(1.0-f)));
Base Color class with three double values.
static double hsl2rgbHelper(double nValue1, double nValue2, double nHue)
BColor hsv2rgb(const BColor &rHSVColor)
Transform from HSV to RGB.
BColor rgb2hsv(const BColor &rRGBColor)
Transform from RGB to HSV.
BColor rgb2hsl(const BColor &rRGBColor)
Transform from RGB to HSL.
BColor hsl2rgb(const BColor &rHSLColor)
Transform from HSL to RGB.