23 #include <type_traits> 39 struct matrix : std::array<std::array<double, 5>, 5>
707 static const argb AlphaShift = 24;
708 static const argb RedShift = 16;
709 static const argb GreenShift = 8;
710 static const argb BlueShift = 0;
715 explicit color(argb aValue);
722 template <
typename T>
723 color(T aRed, T aGreen, T aBlue, T aAlpha = static_cast<T>(0xFF), std::enable_if_t<std::is_integral_v<T>,
sfinae> = {}) :
724 color{
vec4u32{
static_cast<uint32_t
>(aRed), static_cast<uint32_t>(aGreen),
static_cast<uint32_t
>(aBlue), static_cast<uint32_t>(aAlpha) } } {}
725 template <
typename T>
726 color(T aRed, T aGreen, T aBlue, T aAlpha = static_cast<T>(1.0), std::enable_if_t<std::is_same_v<T, double>,
sfinae> = {}) :
727 color{
vec4{ aRed, aGreen, aBlue, aAlpha } } {}
728 template <
typename T>
729 color(T aRed, T aGreen, T aBlue, T aAlpha = static_cast<T>(1.0), std::enable_if_t<std::is_same_v<T, float>,
sfinae> = {}) :
730 color{
vec4f{ aRed, aGreen, aBlue, aAlpha } } {}
731 color(
const std::string& aTextValue);
744 static color from_hsl(
double aHue,
double aSaturation,
double aLightness,
double aAlpha = 1.0);
745 static color from_hsv(
double aHue,
double aSaturation,
double aValue,
double aAlpha = 1.0);
746 static std::optional<color>
from_name(
const std::string& aName);
748 component
alpha()
const;
749 component
red()
const;
750 component
green()
const;
751 component
blue()
const;
752 template <
typename T>
754 template <
typename T>
755 T
red()
const {
return static_cast<T
>(
red()) / 0xFF; }
756 template <
typename T>
758 template <
typename T>
759 T
blue()
const {
return static_cast<T
>(
blue()) / 0xFF; }
760 template <
typename T>
766 template <
typename T>
769 *
this =
color{ red<T>(), green<T>(), blue<T>(), aAlpha };
775 template <
typename T>
780 template <
typename T>
783 return color{ red<T>(), green<T>(), blue<T>(), aAlpha };
797 bool light(
double aThreshold = 0.50)
const;
798 bool dark(
double aThreshold = 0.50)
const;
840 return color{ aLeft.
to_vec4() *=
vec4 { aCoefficient, aCoefficient, aCoefficient, 1.0 } };
843 template <
typename Elem,
typename Traits>
844 inline std::basic_ostream<Elem, Traits>& operator<<(std::basic_ostream<Elem, Traits>& aStream,
const color& aColor)
846 aStream <<
"[A: 0x" << std::hex << (int)aColor.
alpha() <<
847 ", R: 0x" << std::hex << (int)aColor.red() <<
848 ", G: 0x" << std::hex << (int)aColor.green() <<
849 ", B: 0x" << std::hex << (int)aColor.blue() <<
"]";
909 static const std::uint32_t MaxStops = 256;
928 gradient(
const gradient& aOther,
const color_stop_list& aColorStops,
const alpha_stop_list& aAlphaStops);
932 bool use_cache()
const;
933 void set_cache_usage(
bool aUseCache);
934 color_stop_list::const_iterator color_begin()
const;
935 color_stop_list::const_iterator color_end()
const;
936 alpha_stop_list::const_iterator alpha_begin()
const;
937 alpha_stop_list::const_iterator alpha_end()
const;
938 color_stop_list::iterator color_begin();
939 color_stop_list::iterator color_end();
940 alpha_stop_list::iterator alpha_begin();
941 alpha_stop_list::iterator alpha_end();
942 color_stop_list::iterator find_color_stop(
double aPos,
bool aToInsert =
false);
943 color_stop_list::iterator find_color_stop(
double aPos,
double aStart,
double aEnd,
bool aToInsert =
false);
944 alpha_stop_list::iterator find_alpha_stop(
double aPos,
bool aToInsert =
false);
945 alpha_stop_list::iterator find_alpha_stop(
double aPos,
double aStart,
double aEnd,
bool aToInsert =
false);
946 color_stop_list::iterator insert_color_stop(
double aPos);
947 color_stop_list::iterator insert_color_stop(
double aPos,
double aStart,
double aEnd);
948 alpha_stop_list::iterator insert_alpha_stop(
double aPos);
949 alpha_stop_list::iterator insert_alpha_stop(
double aPos,
double aStart,
double aEnd);
950 void erase_stop(color_stop_list::iterator aStop);
951 void erase_stop(alpha_stop_list::iterator aStop);
952 std::size_t color_stop_count()
const;
953 std::size_t alpha_stop_count()
const;
954 color_stop_list combined_stops()
const;
955 color at(
double aPos)
const;
956 color at(
double aPos,
double aStart,
double aEnd)
const;
957 color color_at(
double aPos)
const;
958 color color_at(
double aPos,
double aStart,
double aEnd)
const;
962 template <
typename T>
965 return with_alpha(static_cast<color::component>(aAlpha * 0xFF));
968 template <
typename T>
977 orientation_type orientation()
const;
978 void set_orientation(orientation_type aOrientation);
979 gradient with_orientation(orientation_type aOrientation)
const;
992 double smoothness()
const;
993 void set_smoothness(
double aSmoothness);
994 gradient with_smoothness(
double aSmoothness)
const;
1000 static double normalized_position(
double aPos,
double aStart,
double aEnd);
1002 const color_stop_list& color_stops()
const;
1003 color_stop_list& color_stops();
1004 const alpha_stop_list& alpha_stops()
const;
1005 alpha_stop_list& alpha_stops();
1010 color_stop_list iColorStops;
1011 alpha_stop_list iAlphaStops;
1013 orientation_type iOrientation;
static const color LightYellow1
static const color IndianRed4
static const color RoyalBlue3
static const color SlateGray1
static const color Grey34
static const color Maroon1
static const color Burlywood
static const color LemonChiffon4
static const color PeachPuff
static const color Grey76
static const color DarkSeaGreen2
static const color LightBlue2
static const color Orange2
static const color Gray76
static const color CornflowerBlue
static const color Grey97
static const color Ivory2
static const color PeachPuff2
neolib::variant< corner, double > orientation_type
static const color Grey57
static const color OliveDrab2
static const color SpringGreen
static const color Cornsilk1
static const color Cornsilk3
static const color Gray77
static const color Seashell1
color & lighten(component aDelta)
static const color MistyRose1
static const color Seashell
static const color Gray41
static const color DarkOrchid3
static const color Wheat1
static const color Grey48
static const color Grey33
static const color Grey14
static const color Purple3
static const color BlanchedAlmond
static const color Grey61
static const color SlateGray4
static const color VioletRed2
static const color LightSkyBlue2
static std::optional< color > from_name(const std::string &aName)
static const color Gray70
static const color Goldenrod3
static const color Khaki4
static const color LightYellow3
static const color Gray63
static const color SpringGreen1
static const color Gray28
static const color Purple4
static const color LightPink4
static const color Grey77
static const color Gray61
static const color Grey71
static const color Turquoise2
static const color PaleGreen
static const color MediumOrchid1
static const color Aquamarine
static const color Gray40
static const color Gray80
static const color Grey95
static const color Grey79
static const color Gray10
static const color Grey47
static const color ForestGreen
static const color Grey69
static const color MediumOrchid3
static const color OrangeRed4
static const color CadetBlue
static const color Goldenrod2
static const color Bisque
static const color DarkSlateGray2
static const color AntiqueWhite1
static const color SkyBlue4
static const color Gray19
std::optional< color > optional_color
static const color Gray33
color lighter(component aDelta) const
static const color Coral4
static const color BlueViolet
static const color MistyRose3
static const color DarkSeaGreen4
static const color Thistle3
static const color Orange1
static const color WhiteSmoke
color darker(component aDelta) const
static const color DarkOrchid4
static const color Grey92
static const color Cornsilk
static const color PeachPuff3
static const color Magenta
static const color Gray23
static const color Grey68
bool operator!=(const color &aOther) const
static const color DarkOrange2
static const color SeaGreen4
static const color SteelBlue2
color & set_alpha(T aAlpha, std::enable_if_t< std::is_integral_v< T >, sfinae >={})
static const color DodgerBlue2
static const color LightSkyBlue4
static const color Grey73
static const color Magenta2
static const color Gray96
static const color Gray81
static const color OliveDrab3
static const color Grey13
static const color Gray97
color(T aRed, T aGreen, T aBlue, T aAlpha=static_cast< T >(0xFF), std::enable_if_t< std::is_integral_v< T >, sfinae >={})
static const color Wheat2
static const color OliveDrab4
static const color Salmon3
static const color Gray83
static const color Orange4
color with_blue(component aNewValue) const
static const color Tomato1
static const color Sienna4
static const color DimGray
static const color Gray78
static const color SlateBlue
color shade(component aDelta) const
static const color Gray88
static const color Maroon
static const component MinComponetValue
static const color LightYellow4
static const color Grey98
static const color Gray39
static const color DodgerBlue
static const color PaleVioletRed2
static const color Grey22
static const color Goldenrod4
static const color Gray94
static const color Grey80
gradient with_alpha(T aAlpha, std::enable_if_t< std::is_floating_point_v< T >, sfinae >={})
static const color Firebrick3
static const color LightPink1
static const color AliceBlue
static const color DarkOrange3
static const color Grey56
static const color DodgerBlue1
static const color Seashell2
static const color Bisque2
static const color HotPink
static const color Honeydew4
static const color Seashell3
color & set_alpha(T aAlpha, std::enable_if_t< std::is_floating_point_v< T >, sfinae >={})
std::optional< vec2 > optional_vec2
std::pair< double, color > color_stop
static const color Gray16
static const color DarkOliveGreen2
static const color LightBlue
static const color Gray50
color with_combined_alpha(component aNewValue) const
static const color Gray35
static const color SlateBlue4
static const color LightSalmon2
static const color DarkSlateGray1
static const color Grey36
static const color Orange
std::vector< color_stop > color_stop_list
static const color Grey67
color unshade(component aDelta) const
static const color PapayaWhip
static const color Grey66
static const color Azure2
static const color PaleVioletRed4
color & operator+=(component aDelta)
static const color DeepPink
static const color Burlywood2
static const color Grey37
static const color LightSalmon3
static const color Gray27
static const color MediumPurple4
static const color DeepSkyBlue3
static const color Maroon4
static const color Grey75
static const color Gray13
static const color LightBlue4
color mid(const color &aOther) const
std::string to_hex_string() const
static const color Grey44
static const color Chocolate
color with_alpha(T aAlpha, std::enable_if_t< std::is_floating_point_v< T >, sfinae >={}) const
static const color DeepSkyBlue1
static const color RosyBrown
static const color OliveDrab
static const color DarkViolet
static const color Grey94
static const color LightCyan2
static const color Yellow2
static const color LightSkyBlue3
static const color DarkGoldenrod2
static const color Gray47
static const color Purple1
static const color Ivory1
static const color DarkOrange4
static const color Gray90
static const color Gray69
color with_red(component aNewValue) const
static const color AntiqueWhite2
static const color Tomato4
static const color Grey32
static const color Bisque4
static const color Grey84
static const color Grey51
color(T aRed, T aGreen, T aBlue, T aAlpha=static_cast< T >(1.0), std::enable_if_t< std::is_same_v< T, float >, sfinae >={})
static const color LightCyan3
static const color AntiqueWhite3
static const color Honeydew2
static const color DeepSkyBlue4
static const color Grey99
static const color Ivory3
static const color Grey49
static const color Grey20
bool dark(double aThreshold=0.50) const
static const color Burlywood4
static const color DarkGray
static const color Grey54
static const color Grey12
static const color Grey25
static const color DarkCyan
static const color DarkTurquoise
static const color Gray32
static const color Grey87
static const color CadetBlue1
static const color Purple2
static const color LightSteelBlue2
static const color DarkOrange
static const color LightSteelBlue3
static const color Grey58
static const color Thistle1
static const color DarkOliveGreen4
static const color Gray11
static const color SandyBrown
static const color Grey17
static const color MistyRose
static const color Grey62
static const color Grey38
static const color SlateGray
static const color Gray30
color operator*(const color &aLeft, double aCoefficient)
double brightness() const
static const color Grey81
static const color DimGrey
static const color LightGray
static const color LavenderBlush1
basic_size< coordinate > size
static const component MaxComponetValue
static const color PaleTurquoise1
static const color Magenta1
static const color Brown1
static const color Grey64
static const color Gray82
static const color Grey85
static const color LightGoldenrod3
static const color Grey24
static const color LemonChiffon2
color & set_blue(component aNewValue)
static const color Gray93
static const color LightPink3
static const color PaleVioletRed1
static const color LemonChiffon
static const color Gray49
static const color Yellow
static const color Grey35
static const color SkyBlue2
static const color DeepPink2
static const color HotPink1
static const color Grey96
bool operator==(const color &aOther) const
neolib::variant< color, gradient > color_or_gradient
static const color YellowGreen
static const color LightCoral
color & operator-=(component aDelta)
static const color Grey28
static const color Goldenrod1
static const color Grey27
static const color VioletRed3
static const color Wheat4
static const color DodgerBlue3
static const color Azure4
static const color RosyBrown1
static const color Gray89
static const color Aquamarine3
static const color Grey18
static const color LightGrey
static const color FloralWhite
static const color Chocolate3
static const color Azure3
static const color SeaGreen3
gradient with_combined_alpha(T aAlpha, std::enable_if_t< std::is_floating_point_v< T >, sfinae >={})
static const color RosyBrown3
static const color MistyRose2
static const color Gray26
static const color LightSalmon1
static const color Grey42
static const color Green3
static const color OrangeRed3
static const color SteelBlue3
static const color Khaki2
static const color Gray52
static const color LightSteelBlue1
static const color Gray44
static const color Thistle
static const color HotPink3
static const color Gray43
static const color Grey72
static const color Gray34
static const color Khaki3
static const color PaleTurquoise3
static const color Bisque3
static const color Gray91
static const color SpringGreen3
static color from_hsl(double aHue, double aSaturation, double aLightness, double aAlpha=1.0)
static const color Yellow4
static const color IndianRed
static const color Grey10
static const color DarkKhaki
static const color NavajoWhite4
static const color Chartreuse4
static const color Tomato2
static const color Gray85
static const color Gray57
bool similar_intensity(const color &aOther, double aThreshold=0.5)
static const color MediumPurple
static const color MediumSeaGreen
static const color Coral2
static const color Orchid2
static const color PaleGoldenrod
static const color DarkGoldenrod3
static const color LightYellow
static const color DarkOliveGreen3
static const color PaleVioletRed
static const color Gray95
static const color Grey55
static const color Gray24
static const color Salmon
#define declare_enum_string(enumName, enumEnumerator)
static const color Aquamarine4
static const color Gray75
static const color SkyBlue1
static const color DarkSeaGreen3
static const color Gray86
static const color Firebrick2
static const color DeepSkyBlue2
static const color Gray87
static const color Grey88
static const color SkyBlue
color with_lightness(double aLightness) const
static const color LavenderBlush3
static const color Goldenrod
static const color Gray71
static const color Gray36
static const color Gray79
static const color IndianRed1
static const color Burlywood3
static const color VioletRed
static const color Cornsilk2
static const color VioletRed4
static const color LightSkyBlue
static const color Gray92
static const color Grey41
static const color RoyalBlue2
static const color MediumOrchid
static const color Grey63
color with_green(component aNewValue) const
static const color MediumPurple2
static const color DarkGoldenrod
static const color Gray48
static const color PaleTurquoise
static const color Grey53
static const color Gray42
static const color PeachPuff4
static const color LightCyan
static const color Seashell4
static const color Salmon1
static const color Green1
static const color MediumPurple3
static const color MediumAquamarine
static const color Sienna
static const color Gray56
static const color Gray25
static const color Gray51
static const color NavyBlue
static const color MintCream
static const color Grey19
static const color Gray60
static const color AntiqueWhite
static const color Gray84
static const color Gray38
static const color Grey60
static const color DarkBlue
static const color LightSlateGrey
static const color SpringGreen4
static const color Grey89
static const color Grey23
static const color Turquoise
static const color DarkOrchid1
static const color Gray55
static const color Purple
static const color DarkGoldenrod1
static const color SkyBlue3
static const color Honeydew3
color operator+(const color &aLeft, color::component aRight)
static const color Gray14
static const color Gray45
static const color PaleGreen4
static const color Grey100
static const color PaleGreen1
static const color LightBlue3
static const color LightSkyBlue1
static const color LemonChiffon1
static const color Gray18
static const color DarkGreen
static const color MistyRose4
static const color Cornsilk4
static const color DodgerBlue4
static const color Chartreuse3
static const color OliveDrab1
static const color Gray67
static const color Gray17
static const color LavenderBlush4
static const color Tomato
static const color RoyalBlue1
static const color Bisque1
color & set_green(component aNewValue)
static const color LightSlateBlue
static const color LightPink2
static const color Gray31
static const color Grey65
static const color Gray99
static const color MediumSlateBlue
static const color Firebrick4
static const color Grey26
static const color Coral3
static const color Firebrick1
static const color Salmon2
static const color Honeydew1
static const color Grey31
static const color Grey78
static const color Thistle2
static const color Turquoise1
static const color LemonChiffon3
static const color Gray66
static const color Gray62
static const color Gray98
static const color LightSalmon
static const color Gray59
std::vector< alpha_stop > alpha_stop_list
static const color LightCyan4
static const color MediumVioletRed
static const color Gray73
static const color DarkSeaGreen
color & operator=(const color &aOther)
static const color DeepPink3
static const color Grey91
static const color Aquamarine2
static const color DeepSkyBlue
static const color Grey30
static const color SlateBlue3
static const color Maroon2
static const color Gray21
static const color Thistle4
static const color SteelBlue1
static const color Grey86
static const color NavajoWhite2
static const color Grey82
static const color HotPink2
static const color SlateBlue1
static const color Gray53
static const color DarkOrchid2
static const color DarkSalmon
static const color Gray37
static const color DarkOrange1
static const color PaleTurquoise4
static const color GreenYellow
static const color MediumBlue
static const color Orchid4
static const color Turquoise4
static const color CadetBlue2
static const color IndianRed2
static const color LightBlue1
static const color AntiqueWhite4
static const color Azure1
static const color LightGoldenrod4
static const color PaleGreen3
static const color PowderBlue
static const color Grey90
static const color VioletRed1
static const color LightGoldenrod1
static const color Chartreuse2
static const color DarkGrey
static const color OldLace
static const color LightSeaGreen
static const color Gray15
static const color Gray100
static const color LightCyan1
static const color Grey74
static const color Coral1
static const color Gray68
static const color MediumOrchid4
std::string to_string() const
static const color LightGoldenrod2
static const color RoyalBlue4
color with_alpha(T aAlpha, std::enable_if_t< std::is_integral_v< T >, sfinae >={}) const
static const color Chocolate4
static const color Chartreuse1
static const color Lavender
static const color LightGoldenrodYellow
static const color DeepPink1
static const color SteelBlue4
static const color Gray20
static const color Ivory4
static const color Orchid3
static const color OrangeRed2
static const color Grey50
static const color Gray65
static const color LightSlateGray
static const color DarkSlateGray
static const color MediumSpringGreen
static const color PaleGreen2
static const color MediumTurquoise
static const color DarkSlateGray3
static const color SlateGray2
static const color OrangeRed1
static const color DarkSlateBlue
std::optional< color_or_gradient > optional_color_or_gradient
static const color Grey59
static const color Yellow3
static const color Wheat3
static const color Magenta3
static const color CadetBlue3
static const color LightGoldenrod
static const color Grey70
static const color LimeGreen
static const color DarkRed
static const color Gray58
static const color Green4
static const color Gray46
static const color Orange3
static const color Maroon3
static const color LightGreen
static const color SlateGray3
static const color Chartreuse
static const color PaleTurquoise2
static const color SeaGreen2
static const color OrangeRed
static const color Orchid
static const color Turquoise3
static const color Grey11
color & darken(component aDelta)
static const color Grey15
std::optional< gradient > optional_gradient
static const color Grey43
static const color PeachPuff1
static const color Grey40
static const color LightPink
static const color Grey39
static const color PaleVioletRed3
static const color Yellow1
static const color RoyalBlue
color same_lightness_as(const color &aOther) const
static const color Moccasin
static const color Grey83
static const color Grey46
static const color Gray29
static const color Firebrick
static const color MidnightBlue
static const color Magenta4
static const color DarkOliveGreen1
static const color Green2
static const color Brown4
static const color HotPink4
static const color LawnGreen
color & set_red(component aNewValue)
static const color DarkSeaGreen1
static const color Gray54
static const color NavajoWhite3
static const color Gray74
color(T aRed, T aGreen, T aBlue, T aAlpha=static_cast< T >(1.0), std::enable_if_t< std::is_same_v< T, double >, sfinae >={})
bool light(double aThreshold=0.50) const
static const color Gray72
static const color Chocolate2
static const color Gray12
static const color SaddleBrown
static const color DeepPink4
static const color SeaGreen
static const color DarkOliveGreen
static const color LavenderBlush
std::pair< double, color::component > alpha_stop
static const color Brown3
static const color DarkSlateGrey
static const color Burlywood1
static const color Gray64
static const color Grey45
color operator-(const color &aLeft, color::component aRight)
static const color LavenderBlush2
static const color Brown2
static const color SlateGrey
static const color LightSteelBlue
static const color Orchid1
static const color CadetBlue4
static const color IndianRed3
static const color RosyBrown4
static const color Sienna2
static const color Chocolate1
static const color MediumPurple1
static const color Aquamarine1
bool operator<(const color &aOther) const
static const color SeaGreen1
static const color SteelBlue
static const color Violet
static const color Grey16
static const color Salmon4
static const color Grey93
static const color Gainsboro
std::optional< point > optional_point
static const color Khaki1
static const color LightSteelBlue4
static const color RosyBrown2
static const color NavajoWhite
static const color Sienna1
static const color Grey29
static const color DarkOrchid
static const color SlateBlue2
static const color Tomato3
static const color NavajoWhite1
static const color GhostWhite
static const color Honeydew
static const color DarkSlateGray4
static const color DebianRed
static const color Sienna3
static color from_hsv(double aHue, double aSaturation, double aValue, double aAlpha=1.0)
static const color Grey21
static const color DarkMagenta
static const color DarkGoldenrod4
static const color Gray22
static const color SpringGreen2
static const color LightSalmon4
static const color Grey52
static const color LightYellow2
static const color MediumOrchid2