9 #define MIN3(a,b,c) ( (a)<=(b) ? (a)<=(c)?(a):(c) : (b)<=(c)?(b):(c) ) 10 #define MAX3(a,b,c) ( (a)>=(b) ? (a)>=(c)?(a):(c) : (b)>=(c)?(b):(c) ) 12 inline double fMax(
double a,
double b)
17 inline double fMin(
double a,
double b)
45 if(*
L < 0.5) *
S = (cmax-cmin)/(cmax+cmin);
46 else *
S = (cmax-cmin)/(2.0-cmax-cmin);
56 if(
g == cmax) *
H = 2.0 + (
b-
r) / delta;
57 else *
H = 4.0 + (
r-
g) / delta;
60 if (*
H < 0.0) *
H += 1;
70 double HueToRGB(
const double m1,
const double m2,
double h )
74 if (6.0*
h < 1 )
return (m1+(m2-m1)*
h*6.0);
75 if (2.0*
h < 1 )
return m2;
76 if (3.0*
h < 2.0)
return (m1+(m2-m1)*((2.0/3.0)-
h)*6.0);
113 return RGB(
r*255,
g*255,
b*255);
133 static double H1,
H2,
S1,
S2, L1, L2;
135 if (Ratio<=0)
return Col1;
136 else if (Ratio>=1)
return Col2;
156 const double Ratio) {
157 int R1=(Col1)&0xFF, G1=(Col1>>8)&0xFF, B1=(Col1>>16)&0xFF;
158 int R2=(Col2)&0xFF, G2=(Col2>>8)&0xFF, B2=(Col2>>16)&0xFF;
160 if (Ratio<=0)
return Col1;
161 else if (Ratio>=1)
return Col2;
180 (
R1 + (
R2 -
R1) * (Ratio + 0.02) + 0.5),
181 (G1 + (G2 - G1) * (Ratio - 0.00) + 0.5),
182 (B1 + (B2 - B1) * (Ratio + 0.05) + 0.5)
242 *Lum = (mx + mn) / 510;
245 *Sat = (mx-mn) / (mn+mx);
247 *Sat = (mx-mn) / (510-mn-mx);
267 static BYTE Value(
double m1,
double m2,
double hue)
270 if(hue > 360) hue -= 360;
271 else if(hue < 0) hue += 360;
274 m1 = m1 + (m2 - m1) * hue / 60;
278 m1 = m1 + (m2 - m1) * (240 - hue) / 60;
280 return (
BYTE)(m1 * 255);
296 m2 = Lum + Lum * Sat;
298 m2 = Lum + Sat - Lum * Sat;
323 static double H1,
H2,
S1,
S2, L1, L2;
325 if(Ratio <= 0)
return Col1;
326 else if(Ratio >= 1)
return Col2;
331 return HLStoRGB( H1 , L1 + (L2 - L1) * Ratio,
S1 + (
S2 -
S1) * Ratio * 2);
COLORREF ColorScaleRGB(const COLORREF Col1, const COLORREF Col2, const double Ratio)
double fMax(double a, double b)
GLdouble GLdouble GLdouble r
COLORREF ColorDarker(COLORREF col, double ratio)
#define R2(v, w, x, y, z, i)
GLfloat GLfloat GLfloat GLfloat h
COLORREF ColorLighter(COLORREF col, double ratio)
double HueToRGB(const double m1, const double m2, double h)
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
#define R1(v, w, x, y, z, i)
GLboolean GLboolean GLboolean b
double fMin(double a, double b)
COLORREF ColorScaleHSL(const COLORREF Col1, const COLORREF Col2, const double Ratio)
void RGBtoHLS(const COLORREF rgb, double *H, double *L, double *S)
_In_ ULONG _In_ ULONG rgb
COLORREF HLStoRGB(const double H, const double L, const double S)
GLboolean GLboolean GLboolean GLboolean a
COLORREF ScaleLumRGB(COLORREF col1, double ratio)