TODO: Refactor HSV code so that h is in range [0,360] and s, and v are in range [0-1]. Fix conversions to RGB
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <format>
|
||||
#include <Color4.hpp>
|
||||
|
||||
// Gets set to whatever your terminal emulator is configured for.
|
||||
// This means black can be shown as purple if configured that way.
|
||||
|
@@ -57,9 +57,6 @@ public:
|
||||
/// Constructs a new Color4 from an HSV structure.
|
||||
constexpr explicit Color4(const HSV& hsv, float alpha = 1.f);
|
||||
|
||||
/// Constructs a new Color4 from an HSVA structure.
|
||||
constexpr explicit Color4(const HSVA& hsva);
|
||||
|
||||
/// TODO: HSL to RGB constructor
|
||||
constexpr explicit Color4(const HSL& hsl, float alpha = 1.f);
|
||||
// TODO: LCH to RGB constructor
|
||||
@@ -73,10 +70,8 @@ public:
|
||||
|
||||
static Color4 FromHexA(const std::string& hexACode);
|
||||
|
||||
static Color4 FromHSV(float hue, float saturation, float value, float alpha = 1.f) {
|
||||
// TODO: implement
|
||||
return {};
|
||||
}
|
||||
static Color4 FromHSV(float hue, float saturation, float value, float alpha = 1.f);
|
||||
|
||||
static Color4 FromHSL(float hue, float saturation, float lightness, float alpha = 1.f);
|
||||
static Color4 FromNormalized(float red, float green, float blue, float alpha = 1.f);
|
||||
static Color4 FromLCH(float l, float c, float h, float alpha = 1.f);
|
||||
|
7
main.cpp
7
main.cpp
@@ -21,5 +21,12 @@ int main()
|
||||
mcolor::printAnsiColorTable();
|
||||
mcolor::printRGBConsoleTest();
|
||||
|
||||
|
||||
for (int i = 0; i < 255; i++) {
|
||||
Color4 c = Color4::FromHSV(i/255.f, 1.f, 1.f);
|
||||
std::cout << std::format("{},{},{}", c.r, c.g, c.b) << std::endl;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -116,6 +116,10 @@ Color4 Color4::FromHexA(const std::string &hexACode) {
|
||||
throw std::invalid_argument("Invalid hex code");
|
||||
}
|
||||
|
||||
Color4 Color4::FromHSV(float hue, float saturation, float value, float alpha) {
|
||||
return Color4(HSV{hue, saturation, value}, alpha);
|
||||
}
|
||||
|
||||
u8 Color4::RedChannel() const { return r;}
|
||||
|
||||
u8 Color4::GreenChannel() const { return g;}
|
||||
|
Reference in New Issue
Block a user