MCPcopy Create free account
hub / github.com/duckdb/duckdb / GetHue

Function GetHue

tools/shell/shell_metadata_command.cpp:609–634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607#endif
608
609double GetHue(const HighlightColorInfo &input) {
610 double r = input.r / 255.0;
611 double g = input.g / 255.0;
612 double b = input.b / 255.0;
613
614 double max = std::max({r, g, b});
615 double min = std::min({r, g, b});
616 double delta = max - min;
617
618 if (delta == 0) {
619 return 0;
620 }
621 double hue;
622 if (max == r) {
623 hue = (g - b) / delta;
624 } else if (max == g) {
625 hue = 2.0 + (b - r) / delta;
626 } else {
627 hue = 4.0 + (r - g) / delta;
628 }
629 hue *= 60.0;
630 if (hue < 0) {
631 hue += 360;
632 }
633 return hue;
634}
635
636double GetLum(const HighlightColorInfo &input) {
637 return sqrt(0.241 * input.r + 0.691 * input.g + 0.068 * input.b);

Callers 1

DisplayColorsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected