Change value of Colors::Transparent
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <Color3.hpp>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
using u8 = uint8_t;
|
||||
|
||||
@@ -86,6 +88,12 @@ struct CMYK {
|
||||
float k;
|
||||
};
|
||||
|
||||
class Color4;
|
||||
|
||||
std::string toEscapeCode(Color4 c, bool bg=false);
|
||||
|
||||
void print_builtin_color_list();
|
||||
|
||||
/// A type representing a color with alpha.
|
||||
/// Our default format is RGBA with 8 bits-per-channel.
|
||||
/// Conversions to other color formats are provided.
|
||||
@@ -97,6 +105,7 @@ public:
|
||||
u8 a;
|
||||
public:
|
||||
|
||||
|
||||
/// The default constructor does not initialize any members.
|
||||
Color4() = default;
|
||||
|
||||
@@ -125,6 +134,8 @@ public:
|
||||
|
||||
/// Constructs a new Color4 from an HSVA structure.
|
||||
explicit Color4(const HSVA& hsva);
|
||||
|
||||
/// Constructs a new
|
||||
explicit Color4(const HSL& hsl, float alpha = 1.f);
|
||||
explicit Color4(const LCH& lch, float alpha = 1.f);
|
||||
explicit Color4(const LCHA& lcha);
|
||||
|
@@ -2,174 +2,176 @@
|
||||
|
||||
#include <Color4.hpp>
|
||||
|
||||
#define COLOR static const Color4
|
||||
|
||||
namespace Colors {
|
||||
static const Color4 Transparent{255,255,255,0};
|
||||
COLOR Transparent{0,0,0,0};
|
||||
namespace Primary {
|
||||
static const Color4 Red{255, 0, 0};
|
||||
static const Color4 Green{0, 255, 0};
|
||||
static const Color4 Blue{0, 0, 255};
|
||||
static const Color4 White{255, 255, 255};
|
||||
static const Color4 Black{0, 0, 0};
|
||||
static const Color4 Gray{128, 128, 128};
|
||||
static const Color4 DarkGray{192, 192, 192};
|
||||
static const Color4 LightGray{64, 64, 64};
|
||||
static const Color4 Yellow{255, 255, 0};
|
||||
COLOR Red{255, 0, 0};
|
||||
COLOR Green{0, 255, 0};
|
||||
COLOR Blue{0, 0, 255};
|
||||
COLOR White{255, 255, 255};
|
||||
COLOR Black{0, 0, 0};
|
||||
COLOR Gray{128, 128, 128};
|
||||
COLOR DarkGray{192, 192, 192};
|
||||
COLOR LightGray{64, 64, 64};
|
||||
COLOR Yellow{255, 255, 0};
|
||||
}
|
||||
using namespace Primary;
|
||||
namespace Reds {
|
||||
static const Color4 Fuchsia {255, 0, 255};
|
||||
static const Color4 LightSalmon{255, 160, 122};
|
||||
static const Color4 Salmon{250, 128, 114};
|
||||
static const Color4 DarkSalmon{233, 150, 122};
|
||||
static const Color4 LightCoral{240, 128, 128};
|
||||
static const Color4 IndianRed{205, 92, 92};
|
||||
static const Color4 Crimson{220, 20, 60};
|
||||
static const Color4 Firebrick{178, 34, 34};
|
||||
static const Color4 DarkRed{139, 0, 0};
|
||||
COLOR Fuchsia {255, 0, 255};
|
||||
COLOR LightSalmon{255, 160, 122};
|
||||
COLOR Salmon{250, 128, 114};
|
||||
COLOR DarkSalmon{233, 150, 122};
|
||||
COLOR LightCoral{240, 128, 128};
|
||||
COLOR IndianRed{205, 92, 92};
|
||||
COLOR Crimson{220, 20, 60};
|
||||
COLOR Firebrick{178, 34, 34};
|
||||
COLOR DarkRed{139, 0, 0};
|
||||
}
|
||||
namespace Oranges {
|
||||
static const Color4 Coral{255, 127, 80};
|
||||
static const Color4 Tomato{255, 99, 71};
|
||||
static const Color4 OrangeRed{255, 69, 0};
|
||||
static const Color4 Gold{255, 215, 0};
|
||||
static const Color4 Orange{255, 165, 0};
|
||||
static const Color4 DarkOrange{255, 140, 0};
|
||||
COLOR Coral{255, 127, 80};
|
||||
COLOR Tomato{255, 99, 71};
|
||||
COLOR OrangeRed{255, 69, 0};
|
||||
COLOR Gold{255, 215, 0};
|
||||
COLOR Orange{255, 165, 0};
|
||||
COLOR DarkOrange{255, 140, 0};
|
||||
}
|
||||
namespace Yellows {
|
||||
static const Color4 LightYellow{255, 255, 224};
|
||||
static const Color4 LemonChiffon{255, 250, 205};
|
||||
static const Color4 LightGoldenrodYellow{250, 250, 210};
|
||||
static const Color4 PapayaWhip{255, 239, 213};
|
||||
static const Color4 Moccasin{255, 228, 181};
|
||||
static const Color4 PeachPuff{255, 218, 185};
|
||||
static const Color4 PaleGoldenrod{238, 232, 170};
|
||||
static const Color4 Khaki{240, 230, 140};
|
||||
static const Color4 DarkKhaki{189, 183, 107};
|
||||
COLOR LightYellow{255, 255, 224};
|
||||
COLOR LemonChiffon{255, 250, 205};
|
||||
COLOR LightGoldenrodYellow{250, 250, 210};
|
||||
COLOR PapayaWhip{255, 239, 213};
|
||||
COLOR Moccasin{255, 228, 181};
|
||||
COLOR PeachPuff{255, 218, 185};
|
||||
COLOR PaleGoldenrod{238, 232, 170};
|
||||
COLOR Khaki{240, 230, 140};
|
||||
COLOR DarkKhaki{189, 183, 107};
|
||||
}
|
||||
namespace Greens {
|
||||
static const Color4 LawnGreen{124, 252, 0};
|
||||
static const Color4 Chartreuse{127, 255, 0};
|
||||
static const Color4 LimeGreen{50, 205, 50};
|
||||
static const Color4 ForestGreen{34, 139, 34};
|
||||
static const Color4 DarkGreen{0, 100, 0};
|
||||
static const Color4 GreenYellow{173, 255, 47};
|
||||
static const Color4 YellowGreen{154, 205, 50};
|
||||
static const Color4 SpringGreen{0, 255, 127};
|
||||
static const Color4 MediumSpringGreen{0, 250, 154};
|
||||
static const Color4 LightGreen{144, 238, 144};
|
||||
static const Color4 PaleGreen{152, 251, 152};
|
||||
static const Color4 DarkSeaGreen{143, 188, 143};
|
||||
static const Color4 MediumSeaGreen{60, 179, 113};
|
||||
static const Color4 SeaGreen{46, 139, 87};
|
||||
static const Color4 DarkOliveGreen{85, 107, 47};
|
||||
static const Color4 OliveDrab{107, 142, 35};
|
||||
static const Color4 Lime{0, 255, 0};
|
||||
static const Color4 Olive{128, 128, 0};
|
||||
COLOR LawnGreen{124, 252, 0};
|
||||
COLOR Chartreuse{127, 255, 0};
|
||||
COLOR LimeGreen{50, 205, 50};
|
||||
COLOR ForestGreen{34, 139, 34};
|
||||
COLOR DarkGreen{0, 100, 0};
|
||||
COLOR GreenYellow{173, 255, 47};
|
||||
COLOR YellowGreen{154, 205, 50};
|
||||
COLOR SpringGreen{0, 255, 127};
|
||||
COLOR MediumSpringGreen{0, 250, 154};
|
||||
COLOR LightGreen{144, 238, 144};
|
||||
COLOR PaleGreen{152, 251, 152};
|
||||
COLOR DarkSeaGreen{143, 188, 143};
|
||||
COLOR MediumSeaGreen{60, 179, 113};
|
||||
COLOR SeaGreen{46, 139, 87};
|
||||
COLOR DarkOliveGreen{85, 107, 47};
|
||||
COLOR OliveDrab{107, 142, 35};
|
||||
COLOR Lime{0, 255, 0};
|
||||
COLOR Olive{128, 128, 0};
|
||||
}
|
||||
namespace Cyans {
|
||||
static const Color4 LightCyan{224, 255, 255};
|
||||
static const Color4 Cyan{0, 255, 255};
|
||||
static const Color4 Aqua{0, 255, 255};
|
||||
static const Color4 Aquamarine{127, 255, 212};
|
||||
static const Color4 MediumAquamarine{102, 205, 170};
|
||||
static const Color4 PaleTurquoise{175, 238, 238};
|
||||
static const Color4 Turquoise{64, 224, 208};
|
||||
static const Color4 MediumTurquoise{72, 209, 204};
|
||||
static const Color4 DarkTurquoise{0, 206, 209};
|
||||
static const Color4 LightSeaGreen{32, 178, 170};
|
||||
static const Color4 CadetBlue{95, 158, 160};
|
||||
static const Color4 DarkCyan{0, 139, 139};
|
||||
static const Color4 Teal{0, 128, 128};
|
||||
COLOR LightCyan{224, 255, 255};
|
||||
COLOR Cyan{0, 255, 255};
|
||||
COLOR Aqua{0, 255, 255};
|
||||
COLOR Aquamarine{127, 255, 212};
|
||||
COLOR MediumAquamarine{102, 205, 170};
|
||||
COLOR PaleTurquoise{175, 238, 238};
|
||||
COLOR Turquoise{64, 224, 208};
|
||||
COLOR MediumTurquoise{72, 209, 204};
|
||||
COLOR DarkTurquoise{0, 206, 209};
|
||||
COLOR LightSeaGreen{32, 178, 170};
|
||||
COLOR CadetBlue{95, 158, 160};
|
||||
COLOR DarkCyan{0, 139, 139};
|
||||
COLOR Teal{0, 128, 128};
|
||||
}
|
||||
namespace Blues {
|
||||
static const Color4 PowderBlue{176, 224, 230};
|
||||
static const Color4 LightBlue{173, 216, 230};
|
||||
static const Color4 LightSkyBlue{135, 206, 250};
|
||||
static const Color4 SkyBlue{135, 206, 235};
|
||||
static const Color4 DeepSkyBlue{0, 191, 255};
|
||||
static const Color4 LightSteelBlue{176, 196, 222};
|
||||
static const Color4 DodgerBlue{30, 144, 255};
|
||||
static const Color4 CornflowerBlue{100, 149, 237};
|
||||
static const Color4 SteelBlue{70, 130, 180};
|
||||
static const Color4 RoyalBlue{65, 105, 225};
|
||||
static const Color4 MediumBlue{0, 0, 205};
|
||||
static const Color4 DarkBlue{0, 0, 139};
|
||||
static const Color4 Navy{0, 0, 128};
|
||||
static const Color4 MidnightBlue{25, 25, 112};
|
||||
static const Color4 MediumSlateBlue{123, 104, 238};
|
||||
static const Color4 SlateBlue{106, 90, 205};
|
||||
static const Color4 DarkSlateBlue{72, 61, 139};
|
||||
COLOR PowderBlue{176, 224, 230};
|
||||
COLOR LightBlue{173, 216, 230};
|
||||
COLOR LightSkyBlue{135, 206, 250};
|
||||
COLOR SkyBlue{135, 206, 235};
|
||||
COLOR DeepSkyBlue{0, 191, 255};
|
||||
COLOR LightSteelBlue{176, 196, 222};
|
||||
COLOR DodgerBlue{30, 144, 255};
|
||||
COLOR CornflowerBlue{100, 149, 237};
|
||||
COLOR SteelBlue{70, 130, 180};
|
||||
COLOR RoyalBlue{65, 105, 225};
|
||||
COLOR MediumBlue{0, 0, 205};
|
||||
COLOR DarkBlue{0, 0, 139};
|
||||
COLOR Navy{0, 0, 128};
|
||||
COLOR MidnightBlue{25, 25, 112};
|
||||
COLOR MediumSlateBlue{123, 104, 238};
|
||||
COLOR SlateBlue{106, 90, 205};
|
||||
COLOR DarkSlateBlue{72, 61, 139};
|
||||
}
|
||||
|
||||
|
||||
namespace Purples {
|
||||
static const Color4 Lavender{230, 230, 250};
|
||||
static const Color4 Thistle{216, 191, 216};
|
||||
static const Color4 Plum{221, 160, 221};
|
||||
static const Color4 Violet{238, 160, 221};
|
||||
static const Color4 Orchid{218, 112, 214};
|
||||
static const Color4 Fuchsia{255, 0, 255};
|
||||
static const Color4 Magenta{255, 0, 255};
|
||||
static const Color4 MediumOrchid{186, 85, 211};
|
||||
static const Color4 MediumPurple{147, 112, 219};
|
||||
static const Color4 BlueViolet{138, 43, 226};
|
||||
static const Color4 DarkViolet{148, 0, 211};
|
||||
static const Color4 DarkOrchid{153, 50, 204};
|
||||
static const Color4 DarkMagenta{139, 0, 128};
|
||||
static const Color4 Purple{128, 0, 128};
|
||||
static const Color4 Indigo{75, 0, 130};
|
||||
COLOR Lavender{230, 230, 250};
|
||||
COLOR Thistle{216, 191, 216};
|
||||
COLOR Plum{221, 160, 221};
|
||||
COLOR Violet{238, 160, 221};
|
||||
COLOR Orchid{218, 112, 214};
|
||||
COLOR Fuchsia{255, 0, 255};
|
||||
COLOR Magenta{255, 0, 255};
|
||||
COLOR MediumOrchid{186, 85, 211};
|
||||
COLOR MediumPurple{147, 112, 219};
|
||||
COLOR BlueViolet{138, 43, 226};
|
||||
COLOR DarkViolet{148, 0, 211};
|
||||
COLOR DarkOrchid{153, 50, 204};
|
||||
COLOR DarkMagenta{139, 0, 128};
|
||||
COLOR Purple{128, 0, 128};
|
||||
COLOR Indigo{75, 0, 130};
|
||||
}
|
||||
namespace Pinks {
|
||||
static const Color4 Pink{255, 129, 203};
|
||||
static const Color4 LightPink{255, 182, 193};
|
||||
static const Color4 HotPink{255, 105, 180};
|
||||
static const Color4 DeepPink{255, 20, 147};
|
||||
static const Color4 PaleVioletRed{219, 112, 147};
|
||||
static const Color4 MediumVioletRed{199, 21, 133};
|
||||
COLOR Pink{255, 129, 203};
|
||||
COLOR LightPink{255, 182, 193};
|
||||
COLOR HotPink{255, 105, 180};
|
||||
COLOR DeepPink{255, 20, 147};
|
||||
COLOR PaleVioletRed{219, 112, 147};
|
||||
COLOR MediumVioletRed{199, 21, 133};
|
||||
}
|
||||
namespace Whites {
|
||||
static const Color4 Snow{255, 250, 250};
|
||||
static const Color4 Honeydew{240, 255, 240};
|
||||
static const Color4 MintCream{245, 255, 250};
|
||||
static const Color4 Azure{240, 255, 255};
|
||||
static const Color4 AliceBlue{240, 248, 255};
|
||||
static const Color4 GhostWhite{248, 248, 255};
|
||||
static const Color4 WhiteSmoke{245, 245, 245};
|
||||
static const Color4 SeaShell{255, 245, 238};
|
||||
static const Color4 Beige{245, 245, 220};
|
||||
static const Color4 OldLace{253, 245, 230};
|
||||
static const Color4 FloralWhite{255, 250, 240};
|
||||
static const Color4 Ivory{255, 255, 240};
|
||||
static const Color4 AntiqueWhite{250, 240, 215};
|
||||
static const Color4 Linen{250, 240, 230};
|
||||
static const Color4 LavenderBlush{255, 240, 245};
|
||||
static const Color4 MistyRose{255, 228, 255};
|
||||
COLOR Snow{255, 250, 250};
|
||||
COLOR Honeydew{240, 255, 240};
|
||||
COLOR MintCream{245, 255, 250};
|
||||
COLOR Azure{240, 255, 255};
|
||||
COLOR AliceBlue{240, 248, 255};
|
||||
COLOR GhostWhite{248, 248, 255};
|
||||
COLOR WhiteSmoke{245, 245, 245};
|
||||
COLOR SeaShell{255, 245, 238};
|
||||
COLOR Beige{245, 245, 220};
|
||||
COLOR OldLace{253, 245, 230};
|
||||
COLOR FloralWhite{255, 250, 240};
|
||||
COLOR Ivory{255, 255, 240};
|
||||
COLOR AntiqueWhite{250, 240, 215};
|
||||
COLOR Linen{250, 240, 230};
|
||||
COLOR LavenderBlush{255, 240, 245};
|
||||
COLOR MistyRose{255, 228, 255};
|
||||
}
|
||||
namespace Grays {
|
||||
static const Color4 Gainsboro{220, 220, 220};
|
||||
static const Color4 LightGray{211, 211, 211};
|
||||
static const Color4 Silver{192, 192, 192};
|
||||
static const Color4 DimGray{105, 105, 105};
|
||||
static const Color4 LightSlateGray{119, 136, 153};
|
||||
static const Color4 SlateGray{112, 128, 144};
|
||||
static const Color4 DarkSlateGray{47, 79, 79};
|
||||
COLOR Gainsboro{220, 220, 220};
|
||||
COLOR LightGray{211, 211, 211};
|
||||
COLOR Silver{192, 192, 192};
|
||||
COLOR DimGray{105, 105, 105};
|
||||
COLOR LightSlateGray{119, 136, 153};
|
||||
COLOR SlateGray{112, 128, 144};
|
||||
COLOR DarkSlateGray{47, 79, 79};
|
||||
}
|
||||
namespace Browns {
|
||||
static const Color4 CornSilk{255, 248, 220};
|
||||
static const Color4 BlanchedAlmond{255, 235, 205};
|
||||
static const Color4 Bisque{255, 228, 196};
|
||||
static const Color4 NavajoWhite{255, 222, 173};
|
||||
static const Color4 Wheat{254, 222, 179};
|
||||
static const Color4 BurlyWood{222, 184, 135};
|
||||
static const Color4 Tan{210, 180, 140};
|
||||
static const Color4 RosyBrown{188, 143, 143};
|
||||
static const Color4 SandyBrown{244, 164, 96};
|
||||
static const Color4 GoldenRod{218, 165, 32};
|
||||
static const Color4 Peru{205, 133, 63};
|
||||
static const Color4 Chocolate{210, 105, 30};
|
||||
static const Color4 SaddleBrown{139, 69, 19};
|
||||
static const Color4 Sienna{160, 82, 45};
|
||||
static const Color4 Brown{164, 42, 42};
|
||||
static const Color4 Maroon{128, 0, 0};
|
||||
COLOR CornSilk{255, 248, 220};
|
||||
COLOR BlanchedAlmond{255, 235, 205};
|
||||
COLOR Bisque{255, 228, 196};
|
||||
COLOR NavajoWhite{255, 222, 173};
|
||||
COLOR Wheat{254, 222, 179};
|
||||
COLOR BurlyWood{222, 184, 135};
|
||||
COLOR Tan{210, 180, 140};
|
||||
COLOR RosyBrown{188, 143, 143};
|
||||
COLOR SandyBrown{244, 164, 96};
|
||||
COLOR GoldenRod{218, 165, 32};
|
||||
COLOR Peru{205, 133, 63};
|
||||
COLOR Chocolate{210, 105, 30};
|
||||
COLOR SaddleBrown{139, 69, 19};
|
||||
COLOR Sienna{160, 82, 45};
|
||||
COLOR Brown{164, 42, 42};
|
||||
COLOR Maroon{128, 0, 0};
|
||||
}
|
||||
}
|
2
main.cpp
2
main.cpp
@@ -2,6 +2,7 @@
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <mcolor.h>
|
||||
#include <Color4.hpp>
|
||||
#include <Colors.hpp>
|
||||
|
||||
int main()
|
||||
@@ -10,6 +11,7 @@ int main()
|
||||
mcolor::windowsSaneify();
|
||||
#endif
|
||||
|
||||
print_builtin_color_list();
|
||||
mcolor::printAnsiColorTable();
|
||||
mcolor::printRGBConsoleTest();
|
||||
|
||||
|
@@ -1,6 +1,24 @@
|
||||
#include <Color4.hpp>
|
||||
#include <format>
|
||||
|
||||
Color4::Color4(u8 red, u8 green, u8 blue, u8 alpha) : r(red), g(green), b(blue), a(alpha) {}
|
||||
|
||||
std::vector<Color4> list;
|
||||
|
||||
|
||||
std::string toEscapeCode(Color4 c, bool bg){
|
||||
if (bg)
|
||||
return std::format("\033[48;2;{};{};{}m", c.r, c.g, c.b);
|
||||
|
||||
return std::format("\033[38;2;{};{};{}m", c.r, c.g, c.b);
|
||||
}
|
||||
|
||||
void print_builtin_color_list() {
|
||||
int i = 0;
|
||||
for (const Color4& color : list) {
|
||||
std::cout << toEscapeCode(color) << i << ": " << "Hello, world!" << std::endl;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Color4::Color4(const RGB &rgb, u8 alpha): Color4(rgb.r, rgb.g, rgb.b, alpha) {}
|
||||
|
||||
@@ -58,6 +76,10 @@ Color4::Color4(const HSV &hsv, float alpha) {
|
||||
|
||||
Color4::Color4(const Color3 &color3, u8 alpha) {r = color3.r; g = color3.g; b = color3.b; a = alpha;}
|
||||
|
||||
Color4::Color4(u8 red, u8 green, u8 blue, u8 alpha): r(red), g(green), b(blue), a(alpha) {
|
||||
list.push_back(*this);
|
||||
}
|
||||
|
||||
Color4 Color4::FromColor3(const Color3 &color3, u8 alpha) {return Color4(color3, alpha);}
|
||||
|
||||
Color4 Color4::FromHex(const std::string &hexCode, u8 alpha) {
|
||||
@@ -120,12 +142,6 @@ float Color4::BN() const { return BlueChannelNormalized(); }
|
||||
|
||||
float Color4::AN() const { return AlphaChannelNormalized(); }
|
||||
|
||||
Color4 Color4::FromHex(const std::string &hexCode, u8 alpha) {
|
||||
// TODO: Support alpha in hex code.
|
||||
u8 r, g, b;
|
||||
std::sscanf(hexCode.c_str(), "#%02x%02x%02x", &r, &g, &b);
|
||||
return {r, g, b, alpha};
|
||||
}
|
||||
|
||||
Color4 Color4::FromNormalized(float red, float green, float blue, float alpha) {
|
||||
return {
|
||||
|
Reference in New Issue
Block a user