UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

30 lines (29 loc) 895 B
"use strict"; const index = require("../../utils/index.cjs"); const unpack = require("../../utils/unpack.cjs"); const rgb2hsl = (...args) => { args = unpack(args, "rgba"); let [r, g, b] = args; r /= 255; g /= 255; b /= 255; const minRgb = index.min(r, g, b); const maxRgb = index.max(r, g, b); const l = (maxRgb + minRgb) / 2; let s, h; if (maxRgb === minRgb) { s = 0; h = Number.NaN; } else { s = l < 0.5 ? (maxRgb - minRgb) / (maxRgb + minRgb) : (maxRgb - minRgb) / (2 - maxRgb - minRgb); } if (r == maxRgb) h = (g - b) / (maxRgb - minRgb); else if (g == maxRgb) h = 2 + (b - r) / (maxRgb - minRgb); else if (b == maxRgb) h = 4 + (r - g) / (maxRgb - minRgb); h *= 60; if (h < 0) h += 360; if (args.length > 3 && args[3] !== void 0) return [h, s, l, args[3]]; return [h, s, l]; }; module.exports = rgb2hsl; //# sourceMappingURL=rgb2hsl.cjs.map