public Color getColorAt ( final float FRACTION ) { float fraction = FRACTION < 0f ? 0f : ( FRACTION > 1f ? 1f : FRACTION ) ; float lowerLimit = 0f ; int lowerIndex = 0 ; float upperLimit = 1f ; int upperIndex = 1 ; int index = 0 ; for ( float currentFraction : fractions ) { if ( Float . compare ( currentFraction , fraction ) < 0 ) { lowerLimit = currentFraction ; lowerIndex = index ; } if ( Float . compare ( currentFraction , fraction ) == 0 ) { return colors [ index ] ; } if ( Float . compare ( currentFraction , fraction ) > 0 ) { upperLimit = currentFraction ; upperIndex = index ; break ; } index ++ ; } float interpolationFraction = ( fraction - lowerLimit ) / ( upperLimit - lowerLimit ) ; return interpolateColor ( colors [ lowerIndex ] , colors [ upperIndex ] , interpolationFraction ) ; }
Returns the color that is defined by the given fraction in the linear gradient paint