@macrostrat/column-components
Version:
React rendering primitives for stratigraphic columns
29 lines (28 loc) • 655 B
JavaScript
import "../../utils/type.js";
import unpack from "../../utils/unpack.js";
const { min, max } = Math;
const rgb2hsl = (...args) => {
args = unpack(args, "rgb");
let [r, g, b] = args;
const min_ = min(r, g, b);
const max_ = max(r, g, b);
const delta = max_ - min_;
let h, s, v;
v = max_ / 255;
if (max_ === 0) {
h = Number.NaN;
s = 0;
} else {
s = delta / max_;
if (r === max_) h = (g - b) / delta;
if (g === max_) h = 2 + (b - r) / delta;
if (b === max_) h = 4 + (r - g) / delta;
h *= 60;
if (h < 0) h += 360;
}
return [h, s, v];
};
export {
rgb2hsl as default
};
//# sourceMappingURL=rgb2hsv.js.map