export class export class ColorUtils { private static returns { number } private static random ( ) { return Math . floor ( Math . random ( ) * 255 ) ; } static param { number } r param { number } g param { number } b returns { string } public static RGBtoHex ( r , g , b ) { return ( ( 1 << 24 ) + ( r << 16 ) + ( g << 8 ) + b ) . toString ( 16 ) . slice ( 1 ) ; } static param { ( r : number , g : number , b : number ) => boolean } fn returns { string } public static randomColor ( fn ? ) { let red = ColorUtils . random ( ) ; let green = ColorUtils . random ( ) ; let blue = ColorUtils . random ( ) ; return ( ! fn || fn ( red , green , blue ) ) ? ColorUtils . RGBtoHex ( red , green , blue ) : ColorUtils . randomColor ( fn ) ; } }