private int calculateColor ( float angle ) { float unit = ( float ) ( angle / ( 2 * Math . PI ) ) ; if ( unit < 0 ) { unit += 1 ; } if ( unit <= 0 ) { mColor = COLORS [ 0 ] ; return COLORS [ 0 ] ; } if ( unit >= 1 ) { mColor = COLORS [ COLORS . length - 1 ] ; return COLORS [ COLORS . length - 1 ] ; } float p = unit * ( COLORS . length - 1 ) ; int i = ( int ) p ; p -= i ; int c0 = COLORS [ i ] ; int c1 = COLORS [ i + 1 ] ; int a = ave ( Color . alpha ( c0 ) , Color . alpha ( c1 ) , p ) ; int r = ave ( Color . red ( c0 ) , Color . red ( c1 ) , p ) ; int g = ave ( Color . green ( c0 ) , Color . green ( c1 ) , p ) ; int b = ave ( Color . blue ( c0 ) , Color . blue ( c1 ) , p ) ; mColor = Color . argb ( a , r , g , b ) ; return Color . argb ( a , r , g , b ) ; }
Calculate the color using the supplied angle .