@thi.ng/color
Version:
Array-based color types, CSS parsing, conversions, transformations, declarative theme generation, gradients, presets
20 lines (19 loc) • 522 B
JavaScript
import { clamp01 } from "@thi.ng/math/interval";
import { setC3 } from "@thi.ng/vectors/setc";
import { hueRgb } from "../rgb/hue-rgb.js";
import { __ensureAlpha } from "../internal/ensure.js";
const hslRgb = (out, src) => {
const s = clamp01(src[1]);
const l = clamp01(src[2]);
out = hueRgb(out || src, src[0], __ensureAlpha(src[3]));
const c = (1 - Math.abs(2 * l - 1)) * s;
return setC3(
out,
(out[0] - 0.5) * c + l,
(out[1] - 0.5) * c + l,
(out[2] - 0.5) * c + l
);
};
export {
hslRgb
};