Package icyllis.modernui.animation

# Class ColorEvaluator

java.lang.Object
icyllis.modernui.animation.ColorEvaluator

All Implemented Interfaces:
  `TypeEvaluator<Integer>`

public final class ColorEvaluator extends Object implements TypeEvaluator<Integer>
This evaluator can be used to perform type interpolation between integer values that represent ARGB colors.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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.
  `Integer`
  `evaluate(float fraction, Integer startValue, Integer endValue)`
  This function returns the result of linearly interpolating the start and end values, with `fraction` representing the proportion between the start and end values.
  `static ColorEvaluator`
  `getInstance()`
  Returns an instance of `ColorEvaluator` that may be used in `PropertyValuesHolder.setEvaluator(TypeEvaluator)`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### getInstance

    @Nonnull public static ColorEvaluator getInstance()
    Returns an instance of `ColorEvaluator` that may be used in `PropertyValuesHolder.setEvaluator(TypeEvaluator)`. The same instance may be used in multiple `Animator`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 values
      `startValue` - A 32-bit int value representing colors in the separate bytes of the parameter
      `endValue` - 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

    @Nonnull public Integer evaluate(float fraction, Integer startValue, Integer endValue)
    Description copied from interface: `TypeEvaluator`
    This function returns the result of linearly interpolating the start and end values, with `fraction` representing the proportion between the start and end values. The calculation is a simple parametric calculation: `result = x0 + t * (x1 - x0)`, where `x0` is `startValue`, `x1` is `endValue`, and `t` is `fraction`.
    Specified by:
      `evaluate` in interface `TypeEvaluator<Integer>`
    Parameters:
      `fraction` - The fraction from the starting to the ending values
      `startValue` - The start value.
      `endValue` - The end value.
    Returns:
      A linear interpolation between the start and end values, given the `fraction` parameter.
    See Also:
      - `evaluate(float, int, int)`