import _colors from '../colors.json' ; export interface Color { value : string ; name : string ; romanized : string ; names : string [ ] ; hue : number ; saturation : number ; lightness : number ; } function shuffle < T > ( _arr ) { const array = Array . from ( _arr ) ; let currentIndex = array . length ; let temporaryValue ; let randomIndex ; while ( currentIndex !== 0 ) { randomIndex = Math . floor ( Math . random ( ) * currentIndex ) ; currentIndex -= 1 ; temporaryValue = array [ currentIndex ] ; array [ currentIndex ] = array [ randomIndex ] ; array [ randomIndex ] = temporaryValue ; } return array ; } export const colors = _colors as Color [ ] ; export function getColors ( name ) { if ( name === 'random' ) return shuffle ( colors ) ; return colors . filter ( i => i . names . includes ( name ) ) ; }