export class ColorUtil { static param { string } colorCode memberof static getRGBList ( colorCode ) { if ( colorCode . substr ( 0 , 1 ) == "#" ) { colorCode = colorCode . substring ( 1 ) ; if ( colorCode . length === 3 ) { colorCode = colorCode . substr ( 0 , 1 ) . repeat ( 2 ) + colorCode . substr ( 1 , 1 ) . repeat ( 2 ) + colorCode . substr ( 2 , 1 ) . repeat ( 2 ) ; } const c = parseInt ( colorCode , 16 ) ; return [ c >> 16 & 0xFF , c >> 8 & 0xFF , c & 0xFF ] ; } else if ( colorCode . substr ( 0 , 4 ) == "rgb(" ) { const rgb = colorCode . match ( /\d+/g ) ; if ( rgb && rgb . length >= 3 ) { return [ Number ( rgb [ 0 ] ) , Number ( rgb [ 1 ] ) , Number ( rgb [ 2 ] ) ] ; } return [ 0 , 0 , 0 ] ; } else return [ 0 , 0 , 0 ] ; } private static _regColor : RegExp = new RegExp ( /^#/ ) ; private static _regRGB : RegExp = new RegExp ( /^rgb\(/ ) ; static isColorCode ( value ) { return ( ColorUtil . _regColor . test ( value ) || ColorUtil . _regRGB . test ( value ) ) ; } }