UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

25 lines (24 loc) 692 B
"use strict"; const index = require("../../utils/index.cjs"); const unpack = require("../../utils/unpack.cjs"); const rgb2hcg = (...args) => { const [r, g, b] = unpack(args, "rgb"); const minRgb = index.min(r, g, b); const maxRgb = index.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]; }; module.exports = rgb2hcg; //# sourceMappingURL=rgb2hcg.cjs.map