import { CIRC , FF , HALF } from '../const' ; import { validNum } from '../math/valid' ; const CIRC6 = CIRC / 6 ; export const hsl2rgb = ( h , s , l ) : number [ ] => { let _R ; let G ; let B ; let _h = ( h % CIRC ) / CIRC6 ; const C = s * 2 * ( l < HALF ? l : 1 - l ) ; const X = C * ( 1 - Math . abs ( _h % 2 - 1 ) ) ; _R = G = B = l - C / 2 ; _h = ~ ~ _h ; _R += [ C , X , 0 , 0 , X , C ] [ _h ] ; G += [ X , C , C , X , 0 , 0 ] [ _h ] ; B += [ 0 , 0 , X , C , C , X ] [ _h ] ; return [ validNum ( FF , _R * FF ) , validNum ( FF , G * FF ) , validNum ( FF , B * FF ) ] ; } ;