Package icyllis.modernui.animation
Class ColorEvaluator
java.lang.Object
icyllis.modernui.animation.ColorEvaluator
- All Implemented Interfaces:
TypeEvaluator<Integer>
This evaluator can be used to perform type interpolation between integer
values that represent ARGB colors.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
evaluate
(float fraction, int startValue, int endValue) This function returns the calculated in-between value for a color given integers that represent the start and end values in the four bytes of the 32-bit int.This function returns the result of linearly interpolating the start and end values, withfraction
representing the proportion between the start and end values.static ColorEvaluator
Returns an instance ofColorEvaluator
that may be used inPropertyValuesHolder.setEvaluator(TypeEvaluator)
.
-
Method Details
-
getInstance
Returns an instance ofColorEvaluator
that may be used inPropertyValuesHolder.setEvaluator(TypeEvaluator)
. The same instance may be used in multipleAnimator
s because it holds no state.- Returns:
- An instance of
ColorEvaluator
.
-
evaluate
public static int evaluate(float fraction, int startValue, int endValue) This function returns the calculated in-between value for a color given integers that represent the start and end values in the four bytes of the 32-bit int. Each channel is separately linearly interpolated and the resulting calculated values are recombined into the return value.- Parameters:
fraction
- The fraction from the starting to the ending valuesstartValue
- A 32-bit int value representing colors in the separate bytes of the parameterendValue
- A 32-bit int value representing colors in the separate bytes of the parameter- Returns:
- A value that is calculated to be the linearly interpolated result, derived by separating the start and end values into separate color channels and interpolating each one separately, recombining the resulting values in the same way.
-
evaluate
Description copied from interface:TypeEvaluator
This function returns the result of linearly interpolating the start and end values, withfraction
representing the proportion between the start and end values. The calculation is a simple parametric calculation:result = x0 + t * (x1 - x0)
, wherex0
isstartValue
,x1
isendValue
, andt
isfraction
.- Specified by:
evaluate
in interfaceTypeEvaluator<Integer>
- Parameters:
fraction
- The fraction from the starting to the ending valuesstartValue
- The start value.endValue
- The end value.- Returns:
- A linear interpolation between the start and end values, given the
fraction
parameter. - See Also:
-