All files / libs/games/src/colors hsbToRgb.ts

100% Statements 7/7
100% Branches 3/3
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 81x 1x 1x 1x 1x 1x 1x  
export const hsbToRgb = (h: number, s: number, b: number): [number, number, number] => {
    const sValue = s / 100;
    const bValue = b / 100;
    const k = (n: number) => (n + h / 60) % 6;
    const f = (n: number) => bValue * (1 - sValue * Math.max(0, Math.min(k(n), 4 - k(n), 1)));
    return [255 * f(5), 255 * f(3), 255 * f(1)];
};