qxLib
color.h
Go to the documentation of this file.
1 /**
2 
3  @file color.h
4  @author Khrapov
5  @date 2.11.2020
6  @copyright © Nick Khrapov, 2021. All right reserved.
7 
8 **/
9 #pragma once
10 
13 #include <qx/hash.h>
14 #include <qx/macros/common.h>
17 #include <qx/patterns/singleton.h>
18 
19 #include <algorithm>
20 #include <unordered_map>
21 
23 #include <glm/vec3.hpp>
24 #include <glm/vec4.hpp>
26 
27 /// @see https://www.cssportal.com/html-colors/x11-colors.php
28 // clang-format off
29 #define QX_DETAILS_COLORS(macro)\
30  macro(alice_blue , AliceBlue , aliceblue , 240, 248, 255) \
31  macro(antique_white , AntiqueWhite , antiquewhite , 250, 235, 215) \
32  macro(aqua , Aqua , aqua , 0, 255, 255) \
33  macro(aquamarine , Aquamarine , aquamarine , 127, 255, 212) \
34  macro(azure , Azure , azure , 240, 255, 255) \
35  macro(beige , Beige , beige , 245, 245, 220) \
36  macro(bisque , Bisque , bisque , 255, 228, 196) \
37  macro(black , Black , black , 0, 0, 0) \
38  macro(blanched_almond , BlanchedAlmond , blanchedalmond , 255, 235, 205) \
39  macro(blue , Blue , blue , 0, 0, 255) \
40  macro(blue_violet , BlueViolet , blueviolet , 138, 43, 226) \
41  macro(brown , Brown , brown , 165, 42, 42) \
42  macro(burly_wood , BurlyWood , burlywood , 222, 184, 135) \
43  macro(cadet_blue , CadetBlue , cadetblue , 95, 158, 160) \
44  macro(chartreuse , Chartreuse , chartreuse , 127, 255, 0) \
45  macro(chocolate , Chocolate , chocolate , 210, 105, 30) \
46  macro(coral , Coral , coral , 255, 127, 80) \
47  macro(cornflower_blue , CornflowerBlue , cornflowerblue , 100, 149, 237) \
48  macro(cornsilk , Cornsilk , cornsilk , 255, 248, 220) \
49  macro(crimson , Crimson , crimson , 220, 20, 60) \
50  macro(cyan , Cyan , cyan , 0, 255, 255) \
51  macro(dark_blue , DarkBlue , darkblue , 0, 0, 139) \
52  macro(dark_cyan , DarkCyan , darkcyan , 0, 139, 139) \
53  macro(dark_goldenrod , DarkGoldenrod , darkgoldenrod , 184, 134, 11) \
54  macro(dark_gray , DarkGray , darkgray , 169, 169, 169) \
55  macro(dark_green , DarkGreen , darkgreen , 0, 100, 0) \
56  macro(dark_khaki , DarkKhaki , darkkhaki , 189, 183, 107) \
57  macro(dark_magenta , DarkMagenta , darkmagenta , 139, 0, 139) \
58  macro(dark_olive_green , DarkOliveGreen , darkolivegreen , 85, 107, 47) \
59  macro(dark_orange , DarkOrange , darkorange , 255, 140, 0) \
60  macro(dark_orchid , DarkOrchid , darkorchid , 153, 50, 204) \
61  macro(dark_red , DarkRed , darkred , 139, 0, 0) \
62  macro(dark_salmon , DarkSalmon , darksalmon , 233, 150, 122) \
63  macro(dark_sea_green , DarkSeaGreen , darkseagreen , 143, 188, 143) \
64  macro(dark_slate_blue , DarkSlateBlue , darkslateblue , 72, 61, 139) \
65  macro(dark_slate_gray , DarkSlateGray , darkslategray , 47, 79, 79) \
66  macro(dark_turquoise , DarkTurquoise , darkturquoise , 0, 206, 209) \
67  macro(dark_violet , DarkViolet , darkviolet , 148, 0, 211) \
68  macro(deep_pink , DeepPink , deeppink , 255, 20, 147) \
69  macro(deep_sky_blue , DeepSkyBlue , deepskyblue , 0, 191, 255) \
70  macro(dim_gray , DimGray , dimgray , 105, 105, 105) \
71  macro(dodger_blue , DodgerBlue , dodgerblue , 30, 144, 255) \
72  macro(fire_brick , FireBrick , firebrick , 178, 34, 34) \
73  macro(floral_white , FloralWhite , floralwhite , 255, 250, 240) \
74  macro(forest_green , ForestGreen , forestgreen , 34, 139, 34) \
75  macro(fuchsia , Fuchsia , fuchsia , 255, 0, 255) \
76  macro(gainsboro , Gainsboro , gainsboro , 220, 220, 220) \
77  macro(ghost_white , GhostWhite , ghostwhite , 248, 248, 255) \
78  macro(gold , Gold , gold , 255, 215, 0) \
79  macro(goldenrod , Goldenrod , goldenrod , 218, 165, 32) \
80  macro(gray , Gray , gray , 128, 128, 128) \
81  macro(green , Green , green , 0, 128, 0) \
82  macro(green_yellow , GreenYellow , greenyellow , 173, 255, 47) \
83  macro(honeydew , Honeydew , honeydew , 240, 255, 240) \
84  macro(hot_pink , HotPink , hotpink , 255, 105, 180) \
85  macro(indian_red , IndianRed , indianred , 205, 92, 92) \
86  macro(indigo , Indigo , indigo , 75, 0, 130) \
87  macro(ivory , Ivory , ivory , 255, 255, 240) \
88  macro(khaki , Khaki , khaki , 240, 230, 140) \
89  macro(lavender , Lavender , lavender , 230, 230, 250) \
90  macro(lavender_blush , LavenderBlush , lavenderblush , 255, 240, 245) \
91  macro(lawn_green , LawnGreen , lawngreen , 124, 252, 0) \
92  macro(lemon_chiffon , LemonChiffon , lemonchiffon , 255, 250, 205) \
93  macro(light_blue , LightBlue , lightblue , 173, 216, 230) \
94  macro(light_coral , LightCoral , lightcoral , 240, 128, 128) \
95  macro(light_cyan , LightCyan , lightcyan , 224, 255, 255) \
96  macro(light_goldenrod_yellow , LightGoldenrodYellow , lightgoldenrodyellow , 250, 250, 210) \
97  macro(light_green , LightGreen , lightgreen , 144, 238, 144) \
98  macro(light_grey , LightGrey , lightgrey , 211, 211, 211) \
99  macro(light_pink , LightPink , lightpink , 255, 182, 193) \
100  macro(light_salmon , LightSalmon , lightsalmon , 255, 160, 122) \
101  macro(light_sea_green , LightSeaGreen , lightseagreen , 32, 178, 170) \
102  macro(light_sky_blue , LightSkyBlue , lightskyblue , 135, 206, 250) \
103  macro(light_slate_gray , LightSlateGray , lightslategray , 119, 136, 153) \
104  macro(light_steel_blue , LightSteelBlue , lightsteelblue , 176, 196, 222) \
105  macro(light_yellow , LightYellow , lightyellow , 255, 255, 224) \
106  macro(lime , Lime , lime , 0, 255, 0) \
107  macro(lime_green , LimeGreen , limegreen , 50, 205, 50) \
108  macro(linen , Linen , linen , 250, 240, 230) \
109  macro(magenta , Magenta , magenta , 255, 0, 255) \
110  macro(maroon , Maroon , maroon , 128, 0, 0) \
111  macro(medium_aquamarine , MediumAquamarine , mediumaquamarine , 102, 205, 170) \
112  macro(medium_blue , MediumBlue , mediumblue , 0, 0, 205) \
113  macro(medium_orchid , MediumOrchid , mediumorchid , 186, 85, 211) \
114  macro(medium_purple , MediumPurple , mediumpurple , 147, 112, 219) \
115  macro(medium_sea_green , MediumSeaGreen , mediumseagreen , 60, 179, 113) \
116  macro(medium_slate_blue , MediumSlateBlue , mediumslateblue , 123, 104, 238) \
117  macro(medium_spring_green , MediumSpringGreen , mediumspringgreen , 0, 250, 154) \
118  macro(medium_turquoise , MediumTurquoise , mediumturquoise , 72, 209, 204) \
119  macro(medium_violet_red , MediumVioletRed , mediumvioletred , 199, 21, 133) \
120  macro(midnight_blue , MidnightBlue , midnightblue , 25, 25, 112) \
121  macro(mint_cream , MintCream , mintcream , 245, 255, 250) \
122  macro(misty_rose , MistyRose , mistyrose , 255, 228, 225) \
123  macro(moccasin , Moccasin , moccasin , 255, 228, 181) \
124  macro(navajo_white , NavajoWhite , navajowhite , 255, 222, 173) \
125  macro(navy , Navy , navy , 0, 0, 128) \
126  macro(old_lace , OldLace , oldlace , 253, 245, 230) \
127  macro(olive , Olive , olive , 128, 128, 0) \
128  macro(olive_drab , OliveDrab , olivedrab , 107, 142, 35) \
129  macro(orange , Orange , orange , 255, 165, 0) \
130  macro(orange_red , OrangeRed , orangered , 255, 69, 0) \
131  macro(orchid , Orchid , orchid , 218, 112, 214) \
132  macro(pale_goldenrod , PaleGoldenrod , palegoldenrod , 238, 232, 170) \
133  macro(pale_green , PaleGreen , palegreen , 152, 251, 152) \
134  macro(pale_turquoise , PaleTurquoise , paleturquoise , 175, 238, 238) \
135  macro(pale_violet_red , PaleVioletRed , palevioletred , 219, 112, 147) \
136  macro(papaya_whip , PapayaWhip , papayawhip , 255, 239, 213) \
137  macro(peach_puff , PeachPuff , peachpuff , 255, 218, 185) \
138  macro(peru , Peru , peru , 205, 133, 63) \
139  macro(pink , Pink , pink , 255, 192, 203) \
140  macro(plum , Plum , plum , 221, 160, 221) \
141  macro(powder_blue , PowderBlue , powderblue , 176, 224, 230) \
142  macro(purple , Purple , purple , 128, 0, 128) \
143  macro(red , Red , red , 255, 0, 0) \
144  macro(rosy_brown , RosyBrown , rosybrown , 188, 143, 143) \
145  macro(royal_blue , RoyalBlue , royalblue , 65, 105, 225) \
146  macro(saddle_brown , SaddleBrown , saddlebrown , 139, 69, 19) \
147  macro(salmon , Salmon , salmon , 250, 128, 114) \
148  macro(sandy_brown , SandyBrown , sandybrown , 244, 164, 96) \
149  macro(sea_green , SeaGreen , seagreen , 46, 139, 87) \
150  macro(seashell , Seashell , seashell , 255, 245, 238) \
151  macro(sienna , Sienna , sienna , 160, 82, 45) \
152  macro(silver , Silver , silver , 192, 192, 192) \
153  macro(sky_blue , SkyBlue , skyblue , 135, 206, 235) \
154  macro(slate_blue , SlateBlue , slateblue , 106, 90, 205) \
155  macro(slate_gray , SlateGray , slategray , 112, 128, 144) \
156  macro(snow , Snow , snow , 255, 250, 250) \
157  macro(spring_green , SpringGreen , springgreen , 0, 255, 127) \
158  macro(steel_blue , SteelBlue , steelblue , 70, 130, 180) \
159  macro(tan , Tan , tan , 210, 180, 140) \
160  macro(teal , Teal , teal , 0, 128, 128) \
161  macro(thistle , Thistle , thistle , 216, 191, 216) \
162  macro(tomato , Tomato , tomato , 255, 99, 71) \
163  macro(turquoise , Turquoise , turquoise , 64, 224, 208) \
164  macro(violet , Violet , violet , 238, 130, 238) \
165  macro(wheat , Wheat , wheat , 245, 222, 179) \
166  macro(white , White , white , 255, 255, 255) \
167  macro(white_smoke , WhiteSmoke , whitesmoke , 245, 245, 245) \
168  macro(yellow , Yellow , yellow , 255, 255, 0) \
169  macro(yellow_green , YellowGreen , yellowgreen , 154, 205, 50) \
170  QX_EMPTY_MACRO
171 // clang-format on
172 
173 
174 namespace qx
175 {
176 
177 enum class color_name_type
178 {
179  // | formatter | output example
180  // -------------|-----------|-------------------
181  css_snake, // | {:s} | alice_blue
182  css_pascal, // | {:p} | AliceBlue
183  css_lower, // | {:l} | aliceblue
184  hex_lower, // | {:x[a]} | f0f8ff[ff]
185  hex_upper, // | {:X[a]} | F0F8FF[FF]
186  rgb, // | {:r[a]} | 240,248,255[,255]
187 };
188 
189 /**
190 
191  @class color
192  @brief RGBA color
193  @author Khrapov
194  @date 10.04.2021
195 
196 **/
197 class color
198 {
199  QX_COPYMOVABLE(color);
200 
201 public:
202  constexpr color() noexcept = default;
203 
204  /**
205  @brief color object constructor
206  @details out of bound values will be clamped
207  @param fRed - red component [0.f, 1.f]
208  @param fGreen - green component [0.f, 1.f]
209  @param fBlue - blue component [0.f, 1.f]
210  @param fAlpha - alpha component [0.f, 1.f]
211  **/
212  constexpr color(float fRed, float fGreen, float fBlue, float fAlpha = 1.f) noexcept;
213 
214  /**
215  @brief color object constructor
216  @details out of bound values will be clamped
217  @param nRed - red component [0, 255]
218  @param nGreen - green component [0, 255]
219  @param nBlue - blue component [0, 255]
220  @param nAlpha - alpha component [0, 255]
221  **/
222  constexpr color(int nRed, int nGreen, int nBlue, int nAlpha = 255) noexcept;
223 
224  /**
225  @brief color object constructor
226  @param nHexValue - hex color value in 0xRRGGBBAA format
227  **/
228  constexpr explicit color(u64 nHexValue) noexcept;
229 
230  /**
231  @brief color object constructor
232  @param vec3 - int vector
233  **/
234  constexpr explicit color(const glm::ivec3& vec3) noexcept;
235 
236  /**
237  @brief color object constructor
238  @param vec4 - int vector
239  **/
240  constexpr explicit color(const glm::ivec4& vec4) noexcept;
241 
242  /**
243  @brief Get red component
244  @return - red component
245  **/
246  constexpr float r() const noexcept;
247 
248  /**
249  @brief Get green component
250  @return - green component
251  **/
252  constexpr float g() const noexcept;
253 
254  /**
255  @brief Get blue component
256  @return - blue component
257  **/
258  constexpr float b() const noexcept;
259 
260  /**
261  @brief Get alpha component
262  @return - alpha component
263  **/
264  constexpr float a() const noexcept;
265 
266  /**
267  @brief Get color component
268  @param i - component number [0, 3]
269  @return - component value
270  **/
271  constexpr float& operator[](size_t i) noexcept;
272 
273  /**
274  @brief Get color component
275  @param i - component number [0, 3]
276  @return - component value
277  **/
278  constexpr const float& operator[](size_t i) const noexcept;
279 
280  /**
281  @brief Get red component as decimal
282  @return - red component as decimal
283  **/
284  constexpr int r_dec() const noexcept;
285 
286  /**
287  @brief Get green component as decimal
288  @return - green component as decimal
289  **/
290  constexpr int g_dec() const noexcept;
291 
292  /**
293  @brief Get blue component as decimal
294  @return - blue component as decimal
295  **/
296  constexpr int b_dec() const noexcept;
297 
298  /**
299  @brief Get alpha component as decimal
300  @return - alpha component as decimal
301  **/
302  constexpr int a_dec() const noexcept;
303 
304  /**
305  @brief Get pointer to the first component
306  @return - pointer to the first component
307  **/
308  constexpr const float* data() const noexcept;
309 
310  /**
311  @brief Get color as hex
312  @return - hex color value in 0xRRGGBB format
313  **/
314  constexpr unsigned int hex_rgb() const noexcept;
315 
316  /**
317  @brief Get color as hex
318  @return - hex color value in 0xRRGGBBAA format
319  **/
320  constexpr unsigned int hex_rgba() const noexcept;
321 
322  /**
323  @brief Get color as hex
324  @return - hex color value in 0xAARRGGBB format
325  **/
326  constexpr unsigned int hex_argb() const noexcept;
327 
328  constexpr bool operator==(const color& other) const noexcept;
329  constexpr operator glm::vec3() const noexcept;
330  constexpr operator glm::vec4() const noexcept;
331 
332  /**
333  @brief Add value to red component
334  @details if the new value goes out of range, it will be clamped
335  @param fDeltaValue - delta value
336  **/
337  constexpr void update_r(float fDeltaValue) noexcept;
338 
339  /**
340  @brief Add value to green component
341  @details if the new value goes out of range, it will be clamped
342  @param fDeltaValue - delta value
343  **/
344  constexpr void update_g(float fDeltaValue) noexcept;
345 
346  /**
347  @brief Add value to blue component
348  @details if the new value goes out of range, it will be clamped
349  @param fDeltaValue - delta value
350  **/
351  constexpr void update_b(float fDeltaValue) noexcept;
352 
353  /**
354  @brief Add value to alpha component
355  @details if the new value goes out of range, it will be clamped
356  @param fDeltaValue - delta value
357  **/
358  constexpr void update_a(float fDeltaValue) noexcept;
359 
360  /**
361  @brief Add value to red component
362  @details if the new value goes out of range, it will be clamped
363  @param nDeltaValue - delta value
364  **/
365  constexpr void update_r_dec(int nDeltaValue) noexcept;
366 
367  /**
368  @brief Add value to green component
369  @details if the new value goes out of range, it will be clamped
370  @param nDeltaValue - delta value
371  **/
372  constexpr void update_g_dec(int nDeltaValue) noexcept;
373 
374  /**
375  @brief Add value to blue component
376  @details if the new value goes out of range, it will be clamped
377  @param nDeltaValue - delta value
378  **/
379  constexpr void update_b_dec(int nDeltaValue) noexcept;
380 
381  /**
382  @brief Add value to alpha component
383  @details if the new value goes out of range, it will be clamped
384  @param nDeltaValue - delta value
385  **/
386  constexpr void update_a_dec(int nDeltaValue) noexcept;
387 
388  /**
389  @brief Set new value of red component
390  @details if the new value goes out of range, it will be clamped
391  @param fValue - new value of component
392  **/
393  constexpr void set_r(float fValue) noexcept;
394 
395  /**
396  @brief Set new value of green component
397  @details if the new value goes out of range, it will be clamped
398  @param fValue - new value of component
399  **/
400  constexpr void set_g(float fValue) noexcept;
401 
402  /**
403  @brief Set new value of blue component
404  @details if the new value goes out of range, it will be clamped
405  @param fValue - new value of component
406  **/
407  constexpr void set_b(float fValue) noexcept;
408 
409  /**
410  @brief Set new value of alpha component
411  @details if the new value goes out of range, it will be clamped
412  @param fValue - new value of component
413  **/
414  constexpr void set_a(float fValue) noexcept;
415 
416  /**
417  @brief Set new value of red component
418  @details if the new value goes out of range, it will be clamped
419  @param nValue - new value of component
420  **/
421  constexpr void set_r_dec(int nValue) noexcept;
422 
423  /**
424  @brief Set new value of green component
425  @details if the new value goes out of range, it will be clamped
426  @param nValue - new value of component
427  **/
428  constexpr void set_g_dec(int nValue) noexcept;
429 
430  /**
431  @brief Set new value of blue component
432  @details if the new value goes out of range, it will be clamped
433  @param nValue - new value of component
434  **/
435  constexpr void set_b_dec(int nValue) noexcept;
436 
437  /**
438  @brief Set new value of alpha component
439  @details if the new value goes out of range, it will be clamped
440  @param nValue - new value of component
441  **/
442  constexpr void set_a_dec(int nValue) noexcept;
443 
444  /**
445  @brief Make color darker
446  @param fPercent - dark factor
447  **/
448  constexpr void darken(float fPercent) noexcept;
449 
450  /**
451  @brief Make color brighter
452  @param fPercent - brighter factor
453  **/
454  constexpr void brighten(float fPercent) noexcept;
455 
456  /**
457  @brief Make darker color
458  @param other - original color
459  @param fPercent - dark factor
460  @return - darker color
461  **/
462  constexpr static color darken(const color& other, float fPercent) noexcept;
463 
464  /**
465  @brief Make brighter color
466  @param other - original color
467  @param fPercent - brighter factor
468  @return - brighter color
469  **/
470  constexpr static color brighten(const color& other, float fPercent) noexcept;
471 
472 #define QX_DETAILS_COLOR_METHOD(snakeCaseName, pascalCaseName, lowerCaseName, r, g, b) \
473  static constexpr auto snakeCaseName(float fAlpha = 1.f) noexcept \
474  { \
475  return color(r, g, b, float_to_dec(fAlpha)); \
476  }
477 
478  /// Color functions
479  QX_DETAILS_COLORS(QX_DETAILS_COLOR_METHOD);
480 
481  /**
482  @brief Try to create color from string
483  @param svColorName - color name: css style (alice_blue, AliceBlue, aliceblue) or #F0F8FF or 0xF0F8FFFF(0xRRGGBBAA) or 0xF0F8FF(0xRRGGBB)
484  @return - found color or nullopt
485  **/
486  static std::optional<color> from_string(string_view svColorName) noexcept;
487 
488  /**
489  @brief Generate a color unique for a hash value
490  @param nHash - hash value
491  @return - generated color
492  **/
493  static constexpr color from_hash(size_t nHash) noexcept;
494 
495  /**
496  @brief Get empty color (0, 0, 0, 0)
497  @details - empty color can be useful for out of border values
498  as they won't affect calc result
499  @return - empty color
500  **/
501  static constexpr color empty() noexcept;
502 
503  /**
504  @brief Get number of float components
505  @return - number of float components
506  **/
507  static constexpr size_t size() noexcept;
508 
509 private:
510  /**
511  @brief Clamp a value to a valid range
512  @param fValue - input value
513  @return - clamped value [0.f, 1.f]
514  **/
515  static constexpr float clamp_value(float fValue) noexcept;
516 
517  /**
518  @brief Convert decimal value to float
519  @param nValue - decimal value [0, 255]
520  @return - float value [0.f, 1.f]
521  **/
522  static constexpr float dec_to_float(int nValue) noexcept;
523 
524  /**
525  @brief Convert float value to decimal
526  @param fValue - float value [0.f, 1.f]
527  @return - decimal value [0, 255]
528  **/
529  static constexpr int float_to_dec(float fValue) noexcept;
530 
531  /**
532  @brief Clamp all vector components and assign
533  @param other - color vector
534  **/
535  constexpr void assign_checked(const glm::vec4& other) noexcept;
536 
537  /**
538  @brief Clamp component and assign
539  @param pComponent - component field
540  @param fValue - new component value
541  **/
542  static constexpr void assign_component_checked(float& pComponent, float fValue) noexcept;
543 
544 private:
545  glm::vec4 m_Color = glm::vec4(1.f);
546 };
547 
548 } // namespace qx
549 
550 #include <qx/render/color.inl>
RGBA color.
Definition: color.h:198
constexpr float g() const noexcept
Get green component.
Definition: color.inl:177
constexpr void update_r_dec(int nDeltaValue) noexcept
Add value to red component.
Definition: color.inl:291
constexpr void update_a(float fDeltaValue) noexcept
Add value to alpha component.
Definition: color.inl:286
constexpr int r_dec() const noexcept
Get red component as decimal.
Definition: color.inl:202
static std::optional< color > from_string(string_view svColorName) noexcept
Try to create color from string.
Definition: color.inl:377
constexpr void update_g(float fDeltaValue) noexcept
Add value to green component.
Definition: color.inl:276
constexpr void update_b(float fDeltaValue) noexcept
Add value to blue component.
Definition: color.inl:281
constexpr void darken(float fPercent) noexcept
Make color darker.
Definition: color.inl:351
constexpr int g_dec() const noexcept
Get green component as decimal.
Definition: color.inl:207
constexpr float a() const noexcept
Get alpha component.
Definition: color.inl:187
QX_DETAILS_COLORS(QX_DETAILS_COLOR_METHOD)
Color functions.
constexpr const float * data() const noexcept
Get pointer to the first component.
Definition: color.inl:222
constexpr float b() const noexcept
Get blue component.
Definition: color.inl:182
constexpr float r() const noexcept
Get red component.
Definition: color.inl:172
constexpr void set_g(float fValue) noexcept
Set new value of green component.
Definition: color.inl:316
constexpr float & operator[](size_t i) noexcept
Get color component.
Definition: color.inl:192
constexpr void set_b(float fValue) noexcept
Set new value of blue component.
Definition: color.inl:321
constexpr int b_dec() const noexcept
Get blue component as decimal.
Definition: color.inl:212
static constexpr color from_hash(size_t nHash) noexcept
Generate a color unique for a hash value.
Definition: color.inl:417
static constexpr color empty() noexcept
Get empty color (0, 0, 0, 0)
Definition: color.inl:425
constexpr void update_g_dec(int nDeltaValue) noexcept
Add value to green component.
Definition: color.inl:296
constexpr void set_r(float fValue) noexcept
Set new value of red component.
Definition: color.inl:311
constexpr unsigned int hex_rgba() const noexcept
Get color as hex.
Definition: color.inl:236
constexpr unsigned int hex_rgb() const noexcept
Get color as hex.
Definition: color.inl:227
constexpr void update_r(float fDeltaValue) noexcept
Add value to red component.
Definition: color.inl:271
constexpr int a_dec() const noexcept
Get alpha component as decimal.
Definition: color.inl:217
constexpr void set_g_dec(int nValue) noexcept
Set new value of green component.
Definition: color.inl:336
static constexpr size_t size() noexcept
Get number of float components.
Definition: color.inl:430
constexpr void brighten(float fPercent) noexcept
Make color brighter.
Definition: color.inl:356
constexpr unsigned int hex_argb() const noexcept
Get color as hex.
Definition: color.inl:246
constexpr void update_b_dec(int nDeltaValue) noexcept
Add value to blue component.
Definition: color.inl:301
constexpr void set_r_dec(int nValue) noexcept
Set new value of red component.
Definition: color.inl:331
constexpr void set_b_dec(int nValue) noexcept
Set new value of blue component.
Definition: color.inl:341
constexpr void update_a_dec(int nDeltaValue) noexcept
Add value to alpha component.
Definition: color.inl:306
constexpr void set_a(float fValue) noexcept
Set new value of alpha component.
Definition: color.inl:326
constexpr void set_a_dec(int nValue) noexcept
Set new value of alpha component.
Definition: color.inl:346
#define QX_PUSH_SUPPRESS_ALL_WARNINGS()
Disable all warnings.
#define QX_POP_SUPPRESS_ALL_WARNINGS()
Enable all warnings after QX_PUSH_SUPPRESS_ALL_WARNINGS.
std::uint64_t u64
Definition: typedefs.h:26