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