@macrostrat/column-components
Version:
React rendering primitives for stratigraphic columns
26 lines (25 loc) • 667 B
JavaScript
import { min, max } from "../../utils/index.js";
import unpack from "../../utils/unpack.js";
const rgb2hcg = (...args) => {
const [r, g, b] = unpack(args, "rgb");
const minRgb = min(r, g, b);
const maxRgb = max(r, g, b);
const delta = maxRgb - minRgb;
const c = delta * 100 / 255;
const _g = minRgb / (255 - delta) * 100;
let h;
if (delta === 0) {
h = Number.NaN;
} else {
if (r === maxRgb) h = (g - b) / delta;
if (g === maxRgb) h = 2 + (b - r) / delta;
if (b === maxRgb) h = 4 + (r - g) / delta;
h *= 60;
if (h < 0) h += 360;
}
return [h, c, _g];
};
export {
rgb2hcg as default
};
//# sourceMappingURL=rgb2hcg.js.map