MathLib
Loading...
Searching...
No Matches
Types.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Math/math/Angle.hpp>
4#include <cassert>
5#include <limits>
6#include <cstdint>
7#include <cmath>
8#include <concepts>
9
10
18namespace Color
19{
20
21template <std::floating_point T>
22class BasicUnitRGB;
23
28template <std::integral T>
30{
31public:
35 using value_type = T;
37
41 constexpr BasicRGB() = default;
42 constexpr BasicRGB(value_type r, value_type g, value_type b) : _red{ r }, _green{ g }, _blue{ b } { }
43 constexpr BasicRGB(const std::tuple<T, T, T> &init_value)
44 :
45 _red{ std::get<0>(init_value) },
46 _green{ std::get<1>(init_value) },
47 _blue{ std::get<2>(init_value) }
48 {
49 }
50
52
56 static constexpr BasicRGB<T> min()
57 {
58 const T mn = std::numeric_limits<T>::min();
59
60 return { mn, mn, mn };
61 }
62
63 static constexpr BasicRGB<T> max()
64 {
65 const T mx = std::numeric_limits<T>::max();
66
67 return { mx, mx, mx };
68 }
69
70 static constexpr BasicRGB<T> zero() { return { }; }
72
76 constexpr value_type red() const { return _red; }
77 constexpr value_type green() const { return _green; }
78 constexpr value_type blue() const { return _blue; }
79
80 constexpr value_type r() const { return _red; }
81 constexpr value_type g() const { return _green; }
82 constexpr value_type b() const { return _blue; }
83
84 constexpr void red(value_type input)
85 {
86 _red = input;
87 }
88
89 constexpr void green(value_type input)
90 {
91 _green = input;
92 }
93
94 constexpr void blue(value_type input)
95 {
96 _blue = input;
97 }
98
99 constexpr void r(value_type input)
100 {
101 red( input );
102 }
103
104 constexpr void g(value_type input)
105 {
106 green( input );
107 }
108
109 constexpr void b(value_type input)
110 {
111 blue( input );
112 }
114
118 constexpr operator std::tuple<T, T, T>() const { return std::make_tuple( _red, _green, _blue ); }
120
121protected:
125
129 friend constexpr bool operator ==(const BasicRGB<T> &left, const BasicRGB<T> &right) = default;
130
137 friend constexpr BasicRGB<T> operator +(const BasicRGB<T> &left, const BasicRGB<T> &right)
138 {
139 return { Math::saturate( left.red() + right.red(), min().red(), max().red() ),
140 Math::saturate( left.green() + right.green(), min().green(), max().green() ),
141 Math::saturate( left.blue() + right.blue(), min().blue(), max().blue() )
142 };
143 }
144
145 friend constexpr BasicRGB<T> operator -(const BasicRGB<T> &left, const BasicRGB<T> &right)
146 {
147 return { Math::saturate( left.red() - right.red(), min().red(), max().red() ),
148 Math::saturate( left.green() - right.green(), min().green(), max().green() ),
149 Math::saturate( left.blue() - right.blue(), min().blue(), max().blue() )
150 };
151 }
152
153 friend constexpr BasicRGB<T> operator *(const BasicRGB<T> &left, const BasicRGB<T> &right)
154 {
155 return { Math::saturate( left.red() * right.red(), min().red(), max().red() ),
156 Math::saturate( left.green() * right.green(), min().green(), max().green() ),
157 Math::saturate( left.blue() * right.blue(), min().blue(), max().blue() )
158 };
159 }
160
161 friend constexpr BasicRGB<T> operator *(const BasicRGB<T> &left, T right)
162 {
163 return { Math::saturate( left.red() * right, min().red(), max().red() ),
164 Math::saturate( left.green() * right, min().green(), max().green() ),
165 Math::saturate( left.blue() * right, min().blue(), max().blue() )
166 };
167 }
170
171 friend constexpr T min(const BasicRGB<T> &input)
172 {
173 // We know T is an integral type
174 return std::min( std::min( input.red(), input.green() ), input.blue() );
175 }
176
177 friend constexpr T max(const BasicRGB<T> &input)
178 {
179 // We know T is an integral type
180 return std::max( std::max( input.red(), input.green() ), input.blue() );
181 }
182
183 template <std::floating_point OT>
185 {
186 const OT max_value = std::numeric_limits<T>::max;
187
188 return { input.red() / max_value,
189 input.green() / max_value,
190 input.blue() / max_value };
191 }
192};
193
194
201template <std::floating_point T>
203{
204public:
208 using value_type = T;
210
214 constexpr BasicUnitRGB() = default;
215
217 :
218 _red{ r },
219 _green{ g },
220 _blue{ b }
221 {
222 assert( isNormalized() );
223 }
224 constexpr BasicUnitRGB(const std::tuple<value_type, value_type, value_type> &init_value)
225 :
226 _red{ std::get<0>(init_value) },
227 _green{ std::get<1>(init_value) },
228 _blue{ std::get<2>(init_value) }
229 {
230 assert( isNormalized() );
231 }
232
234 :
235 _red{ other._red },
237 _blue{ other._blue }
238 {
240 }
241
242 template<std::integral OtherT>
244 :
245 _red( other.red() ),
246 _green( other.green() ),
247 _blue( other.blue() )
248 {
249 const T Max{ std::numeric_limits<OtherT>::max() };
250
251 _red /= Max;
252 _green /= Max;
253 _blue /= Max;
254
255 assert( isNormalized() );
256 }
258
263 {
265
266 if ( this == &other )
267 return *this;
268
269 _red = other._red;
270 _green = other._green;
271 _blue = other._blue;
272
273 return *this;
274 }
276
280 static constexpr BasicUnitRGB<T> min() { return zero(); }
281
282 static constexpr BasicUnitRGB<T> max() { return BasicUnitRGB<T>( T{1.0}, T{1.0}, T{1.0} ); }
283
284 static constexpr BasicUnitRGB<T> zero() { return BasicUnitRGB<T>(); }
286
290 constexpr value_type red() const { return _red; }
291 constexpr value_type green() const { return _green; }
292 constexpr value_type blue() const { return _blue; }
293
294 constexpr value_type r() const { return _red; }
295 constexpr value_type g() const { return _green; }
296 constexpr value_type b() const { return _blue; }
297
298 constexpr void red(value_type input)
299 {
301
302 _red = input;
303 }
304
305 constexpr void green(value_type input)
306 {
308
309 _green = input;
310 }
311
312 constexpr void blue(value_type input)
313 {
315
316 _blue = input;
317 }
318
319 constexpr void r(value_type input)
320 {
321 red( input );
322 }
323
324 constexpr void g(value_type input)
325 {
326 green( input );
327 }
328
329 constexpr void b(value_type input)
330 {
331 blue( input );
332 }
334
335 constexpr bool isNormalized() const
336 {
337 return _isInBounds( _red ) &&
338 _isInBounds( _green ) &&
340 }
341
345 constexpr bool isNaN() const { return std::isnan(_red) || std::isnan(_green) || std::isnan(_blue); }
346
347 constexpr bool isInf() const { return std::isinf(_red) || std::isinf(_green) || std::isinf(_blue); }
349
353 constexpr operator std::tuple<value_type, value_type, value_type>() const { return std::make_tuple( _red, _green, _blue ); }
355protected:
359
360 constexpr bool _isInBounds(value_type component) const
361 {
362 return (component >= value_type{0.0}) && (component <= value_type{1.0});
363 }
364
388
400 {
401 return { Math::saturate( left.red() + right.red(), min().red(), max().red() ),
402 Math::saturate( left.green() + right.green(), min().green(), max().green() ),
403 Math::saturate( left.blue() + right.blue(), min().blue(), max().blue() )
404 };
405 }
406
408 {
409 return { Math::saturate( left.red() - right.red(), min().red(), max().red() ),
410 Math::saturate( left.green() - right.green(), min().green(), max().green() ),
411 Math::saturate( left.blue() - right.blue(), min().blue(), max().blue() )
412 };
413 }
414
416 {
417 return { Math::saturate( left.red() * right.red(), min().red(), max().red() ),
418 Math::saturate( left.green() * right.green(), min().green(), max().green() ),
419 Math::saturate( left.blue() * right.blue(), min().blue(), max().blue() )
420 };
421 }
422
424 {
425 return { Math::saturate( left.red() * right, min().red(), max().red() ),
426 Math::saturate( left.green() * right, min().green(), max().green() ),
427 Math::saturate( left.blue() * right, min().blue(), max().blue() )
428 };
429 }
432
433 friend constexpr T min(const BasicUnitRGB<T> &input)
434 {
435 return std::fmin( std::fmin( input.red(), input.green() ), input.blue() );
436 }
437
438 friend constexpr T max(const BasicUnitRGB<T> &input)
439 {
440 return std::fmax( std::fmax( input.red(), input.green() ), input.blue() );
441 }
442};
443
444
453template <std::floating_point T>
455{
456 struct not_checked { };
457
458 explicit constexpr BasicHue(T init_value, struct not_checked )
459 :
461 {
462 }
463
464public:
468 using value_type = T;
470
474 constexpr BasicHue() = default;
476 :
478 {
479 }
480
481 constexpr BasicHue(T init_value)
482 :
483 _value( Math::BasicDegree<T>{ init_value }.modulo() )
484 {
485 }
487
491 T value() const { return _value.value(); }
493
497 operator T() const { return _value.value(); }
498
499 operator Math::BasicDegree<T>() const { return _value; }
501
505 static constexpr BasicHue<T> min() { return zero(); }
506
507 static constexpr BasicHue<T> max() { return BasicHue<T>( Math::BasicDegree<T>::modulus(), not_checked{} ); }
508
509 static constexpr BasicHue<T> zero() { return BasicHue<T>(); }
511
512 constexpr BasicHue<T> modulo() const { return BasicHue<T>( _value.modulo() ); }
513
517 constexpr bool isNaN() const
518 {
519 return _value.isNan();
520 }
521
522 constexpr bool isInf() const
523 {
524 return _value.isInf();
525 }
527
532 {
534 return *this;
535 }
536
538 {
539 _value += other;
540 return *this;
541 }
542
544 {
545 _value += other;
546 return *this;
547 }
548
550 {
552 return *this;
553 }
554
556 {
557 _value -= other;
558 return *this;
559 }
560
562 {
563 _value -= other;
564 return *this;
565 }
566
568 {
570 return *this;
571 }
572
574 {
575 _value *= other;
576 return *this;
577 }
578
580 {
581 _value *= other;
582 return *this;
583 }
584
586 {
588 return *this;
589 }
590
592 {
593 _value /= other;
594 return *this;
595 }
596
598 {
599 _value /= other;
600 return *this;
601 }
603
614 friend constexpr auto operator <=>(const BasicHue<T> &left, const BasicHue<T> &right) = default;
615 friend constexpr auto operator <=>(const BasicHue<T> &left, const Math::BasicDegree<T> &right)
616 {
617 return left.value() <=> right.value();
618 }
619 friend constexpr auto operator <=>(const BasicHue<T> &left, const T &right)
620 {
621 return left.value() <=> right;
622 }
625
637 friend constexpr bool operator ==(const BasicHue<T> &left, const BasicHue<T> &right) = default;
638 friend constexpr bool operator ==(const BasicHue<T> &left, const Math::BasicDegree<T> &right)
639 {
640 return left.value() == right.value();;
641 }
642 friend constexpr bool operator ==(const BasicHue<T> &left, const T &right)
643 {
644 return left.value() == right;
645 }
648
649protected:
651
675
679 friend constexpr BasicHue<T> operator +(const BasicHue<T> &left, const BasicHue<T> &right)
680 {
681 return { left.value() + right.value() };
682 }
683
685 {
686 return { left.value() + right.value() };
687 }
688
690 {
691 return { left.value() + right.value() };
692 }
693
694 friend constexpr BasicHue<T> operator -(const BasicHue<T> &left, const BasicHue<T> &right)
695 {
696 return { left.value() - right.value() };
697 }
698
700 {
701 return { left.value() - right.value() };
702 }
703
705 {
706 return { left.value() - right.value() };
707 }
708
709 friend constexpr BasicHue<T> operator *(const BasicHue<T> &left, const BasicHue<T> &right)
710 {
711 return { left.value() * right.value() };
712 }
713
715 {
716 return { left.value() * right.value() };
717 }
718
720 {
721 return { left.value() * right.value() };
722 }
723
724 friend constexpr BasicHue<T> operator /(const BasicHue<T> &left, const BasicHue<T> &right)
725 {
726 return { left.value() / right.value() };
727 }
728
730 {
731 return { left.value() / right.value() };
732 }
733
735 {
736 return { left.value() / right.value() };
737 }
738
739 friend constexpr BasicHue<T> operator +(const BasicHue<T> &left, const T &right)
740 {
741 return { left.value() + right };
742 }
743
744 friend constexpr BasicHue<T> operator -(const BasicHue<T> &left, const T &right)
745 {
746 return { left.value() - right };
747 }
748
749 friend constexpr BasicHue<T> operator *(const BasicHue<T> &left, const T &right)
750 {
751 return { left.value() * right };
752 }
753
754 friend constexpr BasicHue<T> operator /(const BasicHue<T> &left, const T &right)
755 {
756 return { left.value() / right };
757 }
758
759 friend constexpr BasicHue<T> operator -(const BasicHue<T> &input)
760 {
761 return { -input.value() };
762 }
764};
765
766
773template <std::floating_point T>
775{
776public:
780 using value_type = T;
782
791
795 constexpr BasicHSV() = default;
797 :
798 _hue{ h },
799 _saturation{ s },
800 _value{ v }
801 {
804 }
805 constexpr BasicHSV(const BasicHSV &other)
806 :
807 _hue{ other._hue },
810 {
812 }
814
816 {
818
819 if ( this == &other )
820 return *this;
821
822 _hue = other._hue;
825
826 return *this;
827 }
828
832 static constexpr BasicHSV<T> min()
833 {
834 return { Math::BasicDegree<value_type>(), value_type{0.0}, value_type{0.0} };
835 }
836
837 static constexpr BasicHSV<T> max()
838 {
840 value_type{1.0},
841 value_type{1.0} };
842 }
844
848 constexpr Math::BasicDegree<value_type> hue() const { return _hue; }
849 constexpr value_type saturation() const { return _saturation; }
850 constexpr value_type value() const { return _value; }
851
853 {
854 _hue = input;
855 }
856
858 {
860
862 }
863
864 constexpr void value(value_type input)
865 {
867
868 _value = input;
869 }
871
872 constexpr enum Color hueColor() const
873 {
875
876 if ( _isInBoundsUpTo( mod.value(), 0.0, 60.0 ) )
877 return Red;
878 else if ( _isInBoundsUpTo( mod.value(), 60.0, 120.0 ) )
879 return Yellow;
880 else if ( _isInBoundsUpTo( mod.value(), 120.0, 180.0 ) )
881 return Green;
882 else if ( _isInBoundsUpTo( mod.value(), 180.0, 240.0 ) )
883 return Cyan;
884 else if ( _isInBoundsUpTo( mod.value(), 240.0, 300.0 ) )
885 return Blue;
886
887 // It must be in range 300 - 360
888 return Magenta;
889 }
890
891 constexpr bool isNormalized() const
892 {
896 }
897
901 constexpr bool isNaN() const { return std::isnan(_hue) || std::isnan(_saturation) || std::isnan(_value); }
902
903 constexpr bool isInf() const { return std::isinf(_hue) || std::isinf(_saturation) || std::isinf(_value); }
905
906protected:
910
912 {
913 return (component >= lower_bound) && (component <= upper_bound);
914 }
915
917 {
918 return (component >= lower_bound) && (component < upper_bound);
919 }
920
944
957 friend constexpr BasicHSV<T> operator +(const BasicHSV<T> &left, const BasicHSV<T> &right)
958 {
962 );
963 }
964
965 friend constexpr BasicHSV<T> operator -(const BasicHSV<T> &left, const BasicHSV<T> &right)
966 {
970 );
971 }
974};
975
982template <std::floating_point T>
984{
985public:
989 using value_type = T;
991
1000
1004 constexpr BasicHSL() = default;
1006 :
1007 _hue{ h },
1008 _saturation{ s },
1009 _lightness{ l }
1010 {
1013 }
1014 constexpr BasicHSL(const BasicHSL &other)
1015 :
1016 _hue{ other._hue },
1019 {
1021 }
1023
1025 {
1027
1028 if ( this == &other )
1029 return *this;
1030
1031 _hue = other._hue;
1033 _lightness = other._lightness;
1034
1035 return *this;
1036 }
1037
1041 static constexpr BasicHSL<T> min()
1042 {
1043 return { Math::BasicDegree<value_type>(), value_type{0.0}, value_type{0.0} };
1044 }
1045
1046 static constexpr BasicHSV<T> max()
1047 {
1049 value_type{1.0},
1050 value_type{1.0} };
1051 }
1053
1057 constexpr Math::BasicDegree<value_type> hue() const { return _hue; }
1058 constexpr value_type saturation() const { return _saturation; }
1059 constexpr value_type lightness() const { return _lightness; }
1060
1062 {
1063 _hue = input;
1064 }
1065
1067 {
1068 assert( _isInBounds( input ) );
1069
1071 }
1072
1074 {
1075 assert( _isInBounds( input ) );
1076
1077 _lightness = input;
1078 }
1080
1081 constexpr enum Color hueColor() const
1082 {
1084
1085 if ( _isInBoundsUpTo( mod.value(), 0.0, 60.0 ) )
1086 return Red;
1087 else if ( _isInBoundsUpTo( mod.value(), 60.0, 120.0 ) )
1088 return Yellow;
1089 else if ( _isInBoundsUpTo( mod.value(), 120.0, 180.0 ) )
1090 return Green;
1091 else if ( _isInBoundsUpTo( mod.value(), 180.0, 240.0 ) )
1092 return Cyan;
1093 else if ( _isInBoundsUpTo( mod.value(), 240.0, 300.0 ) )
1094 return Blue;
1095
1096 // It must be in range 300 - 360
1097 return Magenta;
1098 }
1099
1100 constexpr bool isNormalized() const
1101 {
1105 }
1106
1110 constexpr bool isNaN() const { return std::isnan(_hue) || std::isnan(_saturation) || std::isnan(_lightness); }
1111
1112 constexpr bool isInf() const { return std::isinf(_hue) || std::isinf(_saturation) || std::isinf(_lightness); }
1114
1115protected:
1119
1121 {
1122 return (component >= lower_bound) && (component <= upper_bound);
1123 }
1124
1126 {
1127 return (component >= lower_bound) && (component < upper_bound);
1128 }
1129
1153
1167 friend constexpr BasicHSL<T> operator +(const BasicHSL<T> &left, const BasicHSL<T> &right)
1168 {
1169 return { Math::BasicDegree<T>(left.hue() + right.hue()).modulo(),
1171 Math::saturate( left.lightness() + right.lightness(), min().lightness(), max().lightness() )
1172 };
1173 }
1174
1175 friend constexpr BasicHSL<T> operator -(const BasicHSL<T> &left, const BasicHSL<T> &right)
1176 {
1177 return { Math::BasicDegree<T>(left.hue() - right.hue()).modulo(),
1179 Math::saturate( left.lightness() - right.lightness(), min().lightness(), max().lightness() )
1180 };
1181 }
1184};
1185
1186
1207
1222
1229
1235
1237
1249
1261
1263
1264}
constexpr value_type saturation() const
Definition Types.hpp:1058
constexpr value_type lightness() const
Definition Types.hpp:1059
static constexpr BasicHSV< T > max()
Definition Types.hpp:1046
constexpr BasicHSL & operator=(const BasicHSL &other)
Definition Types.hpp:1024
value_type _saturation
Definition Types.hpp:1117
constexpr Math::BasicDegree< value_type > hue() const
Definition Types.hpp:1057
constexpr BasicHSL()=default
constexpr bool _isInBoundsUpTo(value_type component, value_type lower_bound=0.0, value_type upper_bound=1.0) const
Definition Types.hpp:1125
constexpr bool isInf() const
Definition Types.hpp:1112
constexpr enum Color hueColor() const
Definition Types.hpp:1081
value_type _lightness
Definition Types.hpp:1118
constexpr void saturation(value_type input)
Definition Types.hpp:1066
constexpr BasicHSL(Math::BasicDegree< value_type > h, value_type s, value_type l)
Definition Types.hpp:1005
constexpr void hue(Math::BasicDegree< value_type > input)
Definition Types.hpp:1061
constexpr bool _isInBounds(value_type component, value_type lower_bound=0.0, value_type upper_bound=1.0) const
Definition Types.hpp:1120
static constexpr BasicHSL< T > min()
Definition Types.hpp:1041
constexpr bool isNormalized() const
Definition Types.hpp:1100
Math::BasicDegree< value_type > _hue
Definition Types.hpp:1116
constexpr void lightness(value_type input)
Definition Types.hpp:1073
constexpr BasicHSL(const BasicHSL &other)
Definition Types.hpp:1014
constexpr bool isNaN() const
Definition Types.hpp:1110
T value_type
The type of the underlying implementation for each color.
Definition Types.hpp:989
constexpr value_type saturation() const
Definition Types.hpp:849
constexpr BasicHSV(const BasicHSV &other)
Definition Types.hpp:805
static constexpr BasicHSV< T > max()
Definition Types.hpp:837
value_type _saturation
Definition Types.hpp:908
constexpr Math::BasicDegree< value_type > hue() const
Definition Types.hpp:848
constexpr BasicHSV(Math::BasicDegree< value_type > h, value_type s, value_type v)
Definition Types.hpp:796
constexpr bool _isInBoundsUpTo(value_type component, value_type lower_bound=0.0, value_type upper_bound=1.0) const
Definition Types.hpp:916
constexpr bool isInf() const
Definition Types.hpp:903
constexpr void value(value_type input)
Definition Types.hpp:864
constexpr enum Color hueColor() const
Definition Types.hpp:872
constexpr void saturation(value_type input)
Definition Types.hpp:857
constexpr value_type value() const
Definition Types.hpp:850
constexpr void hue(Math::BasicDegree< value_type > input)
Definition Types.hpp:852
constexpr bool _isInBounds(value_type component, value_type lower_bound=0.0, value_type upper_bound=1.0) const
Definition Types.hpp:911
static constexpr BasicHSV< T > min()
Definition Types.hpp:832
constexpr BasicHSV & operator=(const BasicHSV &other)
Definition Types.hpp:815
constexpr bool isNormalized() const
Definition Types.hpp:891
Math::BasicDegree< value_type > _hue
Definition Types.hpp:907
constexpr BasicHSV()=default
value_type _value
Definition Types.hpp:909
constexpr bool isNaN() const
Definition Types.hpp:901
T value_type
The type of the underlying implementation for each color.
Definition Types.hpp:780
constexpr BasicHue(T init_value)
Definition Types.hpp:481
constexpr BasicHue< T > & operator-=(BasicHue< T > other)
Definition Types.hpp:549
friend constexpr BasicHue< T > operator-(const BasicHue< T > &left, const BasicHue< T > &right)
Definition Types.hpp:694
friend constexpr bool operator==(const BasicHue< T > &left, const BasicHue< T > &right)=default
static constexpr BasicHue< T > min()
Definition Types.hpp:505
constexpr BasicHue< T > & operator+=(BasicHue< T > other)
Definition Types.hpp:531
constexpr bool isInf() const
Definition Types.hpp:522
static constexpr BasicHue< T > max()
Definition Types.hpp:507
constexpr BasicHue< T > modulo() const
Definition Types.hpp:512
static constexpr BasicHue< T > zero()
Definition Types.hpp:509
friend constexpr BasicHue< T > operator*(const BasicHue< T > &left, const BasicHue< T > &right)
Definition Types.hpp:709
friend constexpr auto operator<=>(const BasicHue< T > &left, const BasicHue< T > &right)=default
constexpr BasicHue< T > & operator*=(BasicHue< T > other)
Definition Types.hpp:567
T value() const
Definition Types.hpp:491
Math::BasicDegree< T > _value
Definition Types.hpp:650
constexpr BasicHue(Math::BasicDegree< T > init_value)
Definition Types.hpp:475
friend constexpr BasicHue< T > operator/(const BasicHue< T > &left, const BasicHue< T > &right)
Definition Types.hpp:724
constexpr BasicHue< T > & operator/=(BasicHue< T > other)
Definition Types.hpp:585
constexpr BasicHue()=default
constexpr bool isNaN() const
Definition Types.hpp:517
T value_type
The type of the underlying implementation for each color.
Definition Types.hpp:468
friend constexpr BasicHue< T > operator+(const BasicHue< T > &left, const BasicHue< T > &right)
Definition Types.hpp:679
value_type _blue
Definition Types.hpp:124
constexpr void r(value_type input)
Definition Types.hpp:99
value_type _green
Definition Types.hpp:123
constexpr BasicRGB(value_type r, value_type g, value_type b)
Definition Types.hpp:42
static constexpr BasicRGB< T > zero()
Definition Types.hpp:70
static constexpr BasicRGB< T > min()
Definition Types.hpp:56
constexpr void blue(value_type input)
Definition Types.hpp:94
constexpr value_type red() const
Definition Types.hpp:76
friend BasicUnitRGB< OT > normalized(const BasicRGB< T > &input)
Definition Types.hpp:184
constexpr value_type blue() const
Definition Types.hpp:78
static constexpr BasicRGB< T > max()
Definition Types.hpp:63
constexpr value_type g() const
Definition Types.hpp:81
constexpr BasicRGB(const std::tuple< T, T, T > &init_value)
Definition Types.hpp:43
friend constexpr T min(const BasicRGB< T > &input)
Definition Types.hpp:171
value_type _red
Definition Types.hpp:122
constexpr void green(value_type input)
Definition Types.hpp:89
constexpr BasicRGB()=default
Defaults to (0, 0, 0)
constexpr value_type b() const
Definition Types.hpp:82
constexpr value_type r() const
Definition Types.hpp:80
constexpr value_type green() const
Definition Types.hpp:77
constexpr void g(value_type input)
Definition Types.hpp:104
friend constexpr bool operator==(const BasicRGB< T > &left, const BasicRGB< T > &right)=default
friend constexpr T max(const BasicRGB< T > &input)
Definition Types.hpp:177
constexpr void red(value_type input)
Definition Types.hpp:84
constexpr void b(value_type input)
Definition Types.hpp:109
T value_type
The type of the underlying implementation for each color.
Definition Types.hpp:35
value_type _blue
Definition Types.hpp:358
constexpr void r(value_type input)
Definition Types.hpp:319
value_type _green
Definition Types.hpp:357
constexpr void blue(value_type input)
Definition Types.hpp:312
constexpr value_type red() const
Definition Types.hpp:290
constexpr BasicUnitRGB(const std::tuple< value_type, value_type, value_type > &init_value)
Definition Types.hpp:224
static constexpr BasicUnitRGB< T > max()
Definition Types.hpp:282
constexpr BasicUnitRGB< T > & operator=(const BasicUnitRGB< T > &other)
Definition Types.hpp:262
constexpr bool isInf() const
Definition Types.hpp:347
constexpr value_type blue() const
Definition Types.hpp:292
constexpr BasicUnitRGB(value_type r, value_type g, value_type b)
Definition Types.hpp:216
constexpr value_type g() const
Definition Types.hpp:295
value_type _red
Definition Types.hpp:356
constexpr BasicUnitRGB(const BasicUnitRGB< T > &other)
Definition Types.hpp:233
static constexpr BasicUnitRGB< T > min()
Definition Types.hpp:280
constexpr void green(value_type input)
Definition Types.hpp:305
constexpr value_type b() const
Definition Types.hpp:296
constexpr value_type r() const
Definition Types.hpp:294
constexpr value_type green() const
Definition Types.hpp:291
constexpr BasicUnitRGB(const BasicRGB< OtherT > &other)
Definition Types.hpp:243
constexpr void g(value_type input)
Definition Types.hpp:324
friend constexpr T max(const BasicUnitRGB< T > &input)
Definition Types.hpp:438
constexpr bool _isInBounds(value_type component) const
Definition Types.hpp:360
constexpr bool isNormalized() const
Definition Types.hpp:335
constexpr BasicUnitRGB()=default
static constexpr BasicUnitRGB< T > zero()
Definition Types.hpp:284
constexpr void red(value_type input)
Definition Types.hpp:298
constexpr bool isNaN() const
Definition Types.hpp:345
friend constexpr T min(const BasicUnitRGB< T > &input)
Definition Types.hpp:433
constexpr void b(value_type input)
Definition Types.hpp:329
T value_type
The type of the underlying implementation for each color.
Definition Types.hpp:208
static constexpr T modulus()
Definition Angle.hpp:362
constexpr BasicDegree< T > modulo() const
Definition Angle.hpp:363
T value() const
Definition Angle.hpp:293
friend constexpr BasicHSL< T > operator-(const BasicHSL< T > &left, const BasicHSL< T > &right)
Definition Types.hpp:1175
friend constexpr BasicHSL< T > operator+(const BasicHSL< T > &left, const BasicHSL< T > &right)
Definition Types.hpp:1167
friend constexpr BasicHSV< T > operator-(const BasicHSV< T > &left, const BasicHSV< T > &right)
Definition Types.hpp:965
friend constexpr BasicHSV< T > operator+(const BasicHSV< T > &left, const BasicHSV< T > &right)
Definition Types.hpp:957
friend constexpr BasicRGB< T > operator+(const BasicRGB< T > &left, const BasicRGB< T > &right)
Definition Types.hpp:137
friend constexpr BasicRGB< T > operator-(const BasicRGB< T > &left, const BasicRGB< T > &right)
Definition Types.hpp:145
friend constexpr BasicRGB< T > operator*(const BasicRGB< T > &left, const BasicRGB< T > &right)
Definition Types.hpp:153
friend constexpr BasicUnitRGB< T > operator+(const BasicUnitRGB< T > &left, const BasicUnitRGB< T > &right)
Definition Types.hpp:399
friend constexpr BasicUnitRGB< T > operator*(const BasicUnitRGB< T > &left, const BasicUnitRGB< T > &right)
Definition Types.hpp:415
friend constexpr BasicUnitRGB< T > operator-(const BasicUnitRGB< T > &left, const BasicUnitRGB< T > &right)
Definition Types.hpp:407
friend constexpr bool approximately_equal_to(const BasicHSV< T > &value_to_test, const BasicHSV< T > &value_it_should_be, T tolerance=T{0.0002})
Definition Types.hpp:935
friend constexpr bool approximately_equal_to(const BasicHSL< T > &value_to_test, const BasicHSL< T > &value_it_should_be, T tolerance=T{0.0002})
Definition Types.hpp:1144
friend constexpr bool approximately_equal_to(const BasicUnitRGB< T > &value_to_test, const BasicUnitRGB< T > &value_it_should_be, T tolerance=T{0.0002})
Definition Types.hpp:379
friend constexpr bool approximately_equal_to(const BasicHue< T > &value_to_test, const BasicHue< T > &value_it_should_be, T tolerance=T{0.0002})
Definition Types.hpp:668
Definition Angle.hpp:16
constexpr const Type & saturate(const Type &value, const Type &lower_bound, const Type &upper_bound)
Definition Functions.hpp:94