forked from fengjixuchui/XHOOK-WoW-1.12.1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColor.h
159 lines (145 loc) · 2.65 KB
/
Color.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#pragma once
#include <windows.h>
#include "../ImGui/imgui.h"
struct Color
{
int r;
int g;
int b;
int a;
Color()
{
this->r = 0;
this->g = 0;
this->b = 0;
this->a = 255;
}
Color(int r, int g, int b)
{
this->r = r;
this->g = g;
this->b = b;
this->a = 255;
}
Color(int r, int g, int b, int a)
{
this->r = r;
this->g = g;
this->b = b;
this->a = a;
}
Color operator / (float div)
{
Color color = *this;
color.r = color.r / div;
color.g = color.g / div;
color.b = color.b / div;
return color;
}
Color& operator /= (float div)
{
Color& color = *this;
color.r /= div;
color.g /= div;
color.b /= div;
return color;
}
Color& operator *= (float coeff)
{
Color& color = *this;
color.r *= coeff;
color.g *= coeff;
color.b *= coeff;
return color;
}
static Color FromHSB(float hue, float saturation, float brightness)
{
float h = hue == 1.0f ? 0 : hue * 6.0f;
float f = h - (int)h;
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
if (h < 1)
{
return Color(
(unsigned char)(brightness * 255),
(unsigned char)(t * 255),
(unsigned char)(p * 255)
);
}
else if (h < 2)
{
return Color(
(unsigned char)(q * 255),
(unsigned char)(brightness * 255),
(unsigned char)(p * 255)
);
}
else if (h < 3)
{
return Color(
(unsigned char)(p * 255),
(unsigned char)(brightness * 255),
(unsigned char)(t * 255)
);
}
else if (h < 4)
{
return Color(
(unsigned char)(p * 255),
(unsigned char)(q * 255),
(unsigned char)(brightness * 255)
);
}
else if (h < 5)
{
return Color(
(unsigned char)(t * 255),
(unsigned char)(p * 255),
(unsigned char)(brightness * 255)
);
}
else
{
return Color(
(unsigned char)(brightness * 255),
(unsigned char)(p * 255),
(unsigned char)(q * 255)
);
}
}
static Color FromImColor(ImColor color)
{
return Color(
(int)(color.Value.x * 255),
(int)(color.Value.y * 255),
(int)(color.Value.z * 255),
(int)(color.Value.w * 255)
);
}
static ImColor ToImColor(Color color)
{
return ImColor(
color.r / 255.f,
color.g / 255.f,
color.b / 255.f,
color.a / 255.f
);
}
};
class Rainbow
{
public:
float r, g, b, a;
Rainbow(float r, float g, float b)
{
this->r = r;
this->g = g;
this->b = b;
this->a = 255;
}
};
extern Color Red;
extern Color Green;
extern Color White;
extern Color Black;