CORE: allow to print the color to the console with ansi color codes
parent
fb5549aa05
commit
95809b6ebb
|
@ -201,6 +201,21 @@ float Color::getDistance(const glm::vec4 &color, float hue, float saturation, fl
|
|||
return val;
|
||||
}
|
||||
|
||||
core::String Color::print(RGBA rgba) {
|
||||
String buf = toHex(rgba);
|
||||
buf.append(" ");
|
||||
buf.append("\033[38;2;");
|
||||
buf.append(rgba.r).append(";");
|
||||
buf.append(rgba.g).append(";");
|
||||
buf.append(rgba.b).append("m");
|
||||
buf.append("\033[48;2;");
|
||||
buf.append(rgba.r).append(";");
|
||||
buf.append(rgba.g).append(";");
|
||||
buf.append(rgba.b).append("m");
|
||||
buf.append("\u2587").append("\033[0m");
|
||||
return buf;
|
||||
}
|
||||
|
||||
float Color::getDistance(RGBA rgba, RGBA rgba2) {
|
||||
const glm::vec4 &color = core::Color::fromRGBA(rgba);
|
||||
float hue;
|
||||
|
|
|
@ -82,6 +82,8 @@ public:
|
|||
return minIndex;
|
||||
}
|
||||
|
||||
static core::String print(RGBA rgba);
|
||||
|
||||
static int quantize(RGBA* targetBuf, size_t maxTargetBufColors, const RGBA* inputBuf, size_t inputBufColors);
|
||||
|
||||
static glm::vec4 fromRGBA(const RGBA rgba);
|
||||
|
|
Loading…
Reference in New Issue