ReactOS 0.4.15-dev-5865-g640e228
cardcolor.cpp File Reference
#include "cardlib.h"
Include dependency graph for cardcolor.cpp:

Go to the source code of this file.

Macros

#define MakeRGB   RGB
 
#define MIN3(a, b, c)   ( (a)<=(b) ? (a)<=(c)?(a):(c) : (b)<=(c)?(b):(c) )
 
#define MAX3(a, b, c)   ( (a)>=(b) ? (a)>=(c)?(a):(c) : (b)>=(c)?(b):(c) )
 

Functions

double fMax (double a, double b)
 
double fMin (double a, double b)
 
void RGBtoHLS (const COLORREF rgb, double *H, double *L, double *S)
 
double HueToRGB (const double m1, const double m2, double h)
 
COLORREF HLStoRGB (const double H, const double L, const double S)
 
COLORREF ColorScaleHSL (const COLORREF Col1, const COLORREF Col2, const double Ratio)
 
COLORREF ColorScaleRGB (const COLORREF Col1, const COLORREF Col2, const double Ratio)
 
COLORREF ColorDarker (COLORREF col, double ratio)
 
COLORREF ColorLighter (COLORREF col, double ratio)
 

Macro Definition Documentation

◆ MakeRGB

#define MakeRGB   RGB

Definition at line 7 of file cardcolor.cpp.

◆ MAX3

#define MAX3 (   a,
  b,
  c 
)    ( (a)>=(b) ? (a)>=(c)?(a):(c) : (b)>=(c)?(b):(c) )

Definition at line 10 of file cardcolor.cpp.

◆ MIN3

#define MIN3 (   a,
  b,
  c 
)    ( (a)<=(b) ? (a)<=(c)?(a):(c) : (b)<=(c)?(b):(c) )

Definition at line 9 of file cardcolor.cpp.

Function Documentation

◆ ColorDarker()

COLORREF ColorDarker ( COLORREF  col,
double  ratio 
)

Definition at line 188 of file cardcolor.cpp.

189{
190 return ColorScaleHSL(col, RGB(0,0,0), ratio);
191}
COLORREF ColorScaleHSL(const COLORREF Col1, const COLORREF Col2, const double Ratio)
Definition: cardcolor.cpp:131
#define RGB(r, g, b)
Definition: precomp.h:62

◆ ColorLighter()

COLORREF ColorLighter ( COLORREF  col,
double  ratio 
)

Definition at line 193 of file cardcolor.cpp.

194{
195 return ColorScaleHSL(col, RGB(255,255,255), ratio);
196}

◆ ColorScaleHSL()

COLORREF ColorScaleHSL ( const COLORREF  Col1,
const COLORREF  Col2,
const double  Ratio 
)

Definition at line 131 of file cardcolor.cpp.

132{
133 static double H1, H2, S1, S2, L1, L2;
134
135 if (Ratio<=0) return Col1; // Ratio parameter must be between 0 and 1
136 else if (Ratio>=1) return Col2;
137
138 RGBtoHLS( Col1, &H1, &L1, &S1);
139 RGBtoHLS( Col2, &H2, &L2, &S2);
140 return HLStoRGB( H1+(H2-H1)*Ratio, L1+(L2-L1)*Ratio, S1+(S2-S1)*Ratio );
141}
COLORREF HLStoRGB(const double H, const double L, const double S)
Definition: cardcolor.cpp:90
void RGBtoHLS(const COLORREF rgb, double *H, double *L, double *S)
Definition: cardcolor.cpp:29
#define S2(x)
Definition: test.h:219
#define S1(x)
Definition: test.h:218
#define H2(x, y, z)
Definition: md5.c:54

Referenced by ColorDarker(), and ColorLighter().

◆ ColorScaleRGB()

COLORREF ColorScaleRGB ( const COLORREF  Col1,
const COLORREF  Col2,
const double  Ratio 
)

Definition at line 154 of file cardcolor.cpp.

156 {
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;
159
160 if (Ratio<=0) return Col1; // Ratio parameter must be between 0 and 1
161 else if (Ratio>=1) return Col2;
162
163/* return RGB(
164 (R1 + (R2 - R1) * (Ratio + 0.02) + 0.5), // rounding
165 (G1 + (G2 - G1) * (Ratio - 0.00) + 0.5),
166 (B1 + (B2 - B1) * (Ratio + 0.05) + 0.5)
167 );*/
168
169 /*double r = Ratio;
170 if(Col2 == 0)
171 r = 1-Ratio;
172 else
173 r = 1+Ratio;
174 R1 = (int)(double(R1) * r + 0.5);
175 G1 = (int)(double(G1) * r + 0.5);
176 B1 = (int)(double(B1) * r + 0.5);
177 return RGB(R1,G1,B1);*/
178
179 return RGB(
180 (R1 + (R2 - R1) * (Ratio + 0.02) + 0.5), // rounding
181 (G1 + (G2 - G1) * (Ratio - 0.00) + 0.5),
182 (B1 + (B2 - B1) * (Ratio + 0.05) + 0.5)
183 );
184}
#define R1(v, w, x, y, z, i)
Definition: sha1.c:36
#define R2(v, w, x, y, z, i)
Definition: sha1.c:37

Referenced by CardButton::GetFace(), CardButton::GetHighlight(), CardButton::GetShadow(), GetSinkCols(), and CardWindow::SetBackColor().

◆ fMax()

double fMax ( double  a,
double  b 
)
inline

Definition at line 12 of file cardcolor.cpp.

13{
14 return a < b ? b : a;
15}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79

◆ fMin()

double fMin ( double  a,
double  b 
)
inline

Definition at line 17 of file cardcolor.cpp.

18{
19 return a < b ? a : b;
20}

◆ HLStoRGB()

COLORREF HLStoRGB ( const double  H,
const double  L,
const double  S 
)

Definition at line 90 of file cardcolor.cpp.

91{
92 double r,g,b;
93 double m1, m2;
94
95 if(S == 0)
96 {
97 r = g = b = L;
98 }
99 else
100 {
101 if (L <= 0.5)
102 m2 = L * (1.0 + S);
103 else
104 m2 = L + S - L * S;
105
106 m1 = 2.0 * L - m2;
107
108 r = HueToRGB(m1,m2,H+1.0/3.0);
109 g = HueToRGB(m1,m2,H);
110 b = HueToRGB(m1,m2,H-1.0/3.0);
111 }
112
113 return RGB(r*255, g*255, b*255);
114}
double HueToRGB(const double m1, const double m2, double h)
Definition: cardcolor.cpp:70
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
#define H
#define L(x)
Definition: ntvdm.h:50
#define S(x)
Definition: test.h:217
Definition: movable.cpp:9

Referenced by ColorScaleHSL().

◆ HueToRGB()

double HueToRGB ( const double  m1,
const double  m2,
double  h 
)

Definition at line 70 of file cardcolor.cpp.

71{
72 if (h<0) h+=1.0;
73 if (h>1) h-=1.0;
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);
77 return m1;
78}
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723

Referenced by HLStoRGB().

◆ RGBtoHLS()

void RGBtoHLS ( const COLORREF  rgb,
double H,
double L,
double S 
)

Definition at line 29 of file cardcolor.cpp.

30{
31 double delta;
32 double r = (double)((rgb )&0xFF)/255;
33 double g = (double)((rgb>> 8)&0xFF)/255;
34 double b = (double)((rgb>>16)&0xFF)/255;
35 double cmax = MAX3(r,g,b);
36 double cmin = MIN3(r,g,b);
37 *L=(cmax+cmin)/2.0;
38
39 if(cmax == cmin)
40 {
41 *S = *H = 0; // it's really undefined
42 }
43 else
44 {
45 if(*L < 0.5) *S = (cmax-cmin)/(cmax+cmin);
46 else *S = (cmax-cmin)/(2.0-cmax-cmin);
47
48 delta = cmax - cmin;
49
50 if(r == cmax)
51 {
52 *H = (g - b) / delta;
53 }
54 else
55 {
56 if(g == cmax) *H = 2.0 + (b-r) / delta;
57 else *H = 4.0 + (r-g) / delta;
58 }
59 *H /= 6.0;
60 if (*H < 0.0) *H += 1;
61 }
62}
#define MAX3(a, b, c)
Definition: cardcolor.cpp:10
#define MIN3(a, b, c)
Definition: cardcolor.cpp:9
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3521

Referenced by ColorScaleHSL().