/// <reference path="../editor/defaultEnv.d.ts" />

export const lib: Lib = {
    hsl2rgb(h, s, l): [number, number, number] {
        // https://stackoverflow.com/a/44134328
        l /= 100;
        const a = s * Math.min(l, 1 - l) / 100;
        const f = n => {
            const k = (n + h / 30) % 12;
            const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
            return Math.round(255 * color)
        };
        return [f(0), f(8), f(4)];

    },
}