2 #include "oxygine-include.h" 3 #include "ScalarMath.h" 15 AliceBlue = 0xF0F8FFFF,
16 AntiqueWhite = 0xFAEBD7FF,
18 Aquamarine = 0x7FFFD4FF,
23 BlanchedAlmond = 0xFFEBCDFF,
25 BlueViolet = 0x8A2BE2FF,
27 BurlyWood = 0xDEB887FF,
28 CadetBlue = 0x5F9EA0FF,
29 Chartreuse = 0x7FFF00FF,
30 Chocolate = 0xD2691EFF,
32 CornflowerBlue = 0x6495EDFF,
33 Cornsilk = 0xFFF8DCFF,
36 DarkBlue = 0x00008BFF,
37 DarkCyan = 0x008B8BFF,
38 DarkGoldenrod = 0xB8860BFF,
39 DarkGray = 0xA9A9A9FF,
40 DarkGreen = 0x006400FF,
41 DarkKhaki = 0xBDB76BFF,
42 DarkMagenta = 0x8B008BFF,
43 DarkOliveGreen = 0x556B2FFF,
44 DarkOrange = 0xFF8C00FF,
45 DarkOrchid = 0x9932CCFF,
47 DarkSalmon = 0xE9967AFF,
48 DarkSeaGreen = 0x8FBC8BFF,
49 DarkSlateBlue = 0x483D8BFF,
50 DarkSlateGray = 0x2F4F4FFF,
51 DarkTurquoise = 0x00CED1FF,
52 DarkViolet = 0x9400D3FF,
53 DeepPink = 0xFF1493FF,
54 DeepSkyBlue = 0x00BFFFFF,
56 DodgerBlue = 0x1E90FFFF,
57 Firebrick = 0xB22222FF,
58 FloralWhite = 0xFFFAF0FF,
59 ForestGreen = 0x228B22FF,
61 Gainsboro = 0xDCDCDCFF,
62 GhostWhite = 0xF8F8FFFF,
64 Goldenrod = 0xDAA520FF,
67 GreenYellow = 0xADFF2FFF,
68 Honeydew = 0xF0FFF0FF,
70 IndianRed = 0xCD5C5CFF,
74 Lavender = 0xE6E6FAFF,
75 LavenderBlush = 0xFFF0F5FF,
76 LawnGreen = 0x7CFC00FF,
77 LemonChiffon = 0xFFFACDFF,
78 LightBlue = 0xADD8E6FF,
79 LightCoral = 0xF08080FF,
80 LightCyan = 0xE0FFFFFF,
81 LightGoldenrodYellow = 0xFAFAD2FF,
82 LightGray = 0xD3D3D3FF,
83 LightGreen = 0x90EE90FF,
84 LightPink = 0xFFB6C1FF,
85 LightSalmon = 0xFFA07AFF,
86 LightSeaGreen = 0x20B2AAFF,
87 LightSkyBlue = 0x87CEFAFF,
88 LightSlateGray = 0x778899FF,
89 LightSteelBlue = 0xB0C4DEFF,
90 LightYellow = 0xFFFFE0FF,
92 LimeGreen = 0x32CD32FF,
96 MediumAquamarine = 0x66CDAAFF,
97 MediumBlue = 0x0000CDFF,
98 MediumOrchid = 0xBA55D3FF,
99 MediumPurple = 0x9370DBFF,
100 MediumSeaGreen = 0x3CB371FF,
101 MediumSlateBlue = 0x7B68EEFF,
102 MediumSpringGreen = 0x00FA9AFF,
103 MediumTurquoise = 0x48D1CCFF,
104 MediumVioletRed = 0xC71585FF,
105 MidnightBlue = 0x191970FF,
106 MintCream = 0xF5FFFAFF,
107 MistyRose = 0xFFE4E1FF,
108 Moccasin = 0xFFE4B5FF,
109 NavajoWhite = 0xFFDEADFF,
111 OldLace = 0xFDF5E6FF,
113 OliveDrab = 0x6B8E23FF,
115 OrangeRed = 0xFF4500FF,
117 PaleGoldenrod = 0xEEE8AAFF,
118 PaleGreen = 0x98FB98FF,
119 PaleTurquoise = 0xAFEEEEFF,
120 PaleVioletRed = 0xDB7093FF,
121 PapayaWhip = 0xFFEFD5FF,
122 PeachPuff = 0xFFDAB9FF,
126 PowderBlue = 0xB0E0E6FF,
129 RosyBrown = 0xBC8F8FFF,
130 RoyalBlue = 0x4169E1FF,
131 SaddleBrown = 0x8B4513FF,
133 SandyBrown = 0xF4A460FF,
134 SeaGreen = 0x2E8B57FF,
135 SeaShell = 0xFFF5EEFF,
138 SkyBlue = 0x87CEEBFF,
139 SlateBlue = 0x6A5ACDFF,
140 SlateGray = 0x708090FF,
142 SpringGreen = 0x00FF7FFF,
143 SteelBlue = 0x4682B4FF,
146 Thistle = 0xD8BFD8FF,
148 Turquoise = 0x40E0D0FF,
152 WhiteSmoke = 0xF5F5F5FF,
154 YellowGreen = 0x9ACD32FF
157 Color(): argb(0xffffffff) {}
158 Color(
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a = 255)
166 static Color fromRGBA(
unsigned int rgba)
168 return Color(rgba & 0xFF, (rgba >> 8) & 0xFF, (rgba >> 16) & 0xFF, rgba >> 24);
175 g = (abgr >> 16) & 0xFF;
176 b = (abgr >> 8) & 0xFF;
181 Color(
unsigned int abgr,
unsigned char a_)
184 g = (abgr >> 16) & 0xFF;
185 b = (abgr >> 8) & 0xFF;
189 unsigned char operator [](
int i)
const 195 unsigned int rgba()
const 198 unsigned char* p = (
unsigned char*)(&c);
206 static Color lerp(
const Color& a,
const Color& b,
float v)
209 for (
int i = 0; i < 4; ++i)
210 c.colors[i] = oxygine::lerp(a.colors[i], b.colors[i], v);
215 float getRedF()
const {
return r / 255.0f;}
216 float getGreenF()
const {
return g / 255.0f;}
217 float getBlueF()
const {
return b / 255.0f;}
218 float getAlphaF()
const {
return a / 255.0f;}
220 Vector4 toVector()
const {
return Vector4(getRedF(), getGreenF(), getBlueF(), getAlphaF()); }
222 Color operator + (
const Color& c)
const 225 scalar::clamp(r + c.r, 0, 255),
226 scalar::clamp(g + c.g, 0, 255),
227 scalar::clamp(b + c.b, 0, 255),
228 scalar::clamp(a + c.a, 0, 255));
232 Color operator - (
const Color& c)
const 235 scalar::clamp(r - c.r, 0, 255),
236 scalar::clamp(g - c.g, 0, 255),
237 scalar::clamp(b - c.b, 0, 255),
238 scalar::clamp(a - c.a, 0, 255));
243 Color operator * (
const Color& c)
const 274 Color premultiplied()
const 277 c.r = (c.r * a) / 255;
278 c.g = (c.g * a) / 255;
279 c.b = (c.b * a) / 255;
284 Color withAlpha(
unsigned char alpha)
const 291 bool operator == (
const Color& color)
const 293 return argb == color.argb;
296 bool operator != (
const Color& color)
const 298 return argb != color.argb;
305 unsigned char a, r, g, b;
308 unsigned char colors[4];
312 inline Color lerp(
const Color& a,
const Color& b,
float v)
314 return Color::lerp(a, b, v);
Color(unsigned int abgr, unsigned char a_)
Definition: Color.h:181
–oxgl-end–!
Definition: Actor.h:14
Color(unsigned int abgr)
Definition: Color.h:172