integerInterpolate function

Tuple2<int, double> integerInterpolate(
  1. int start,
  2. int end,
  3. double alpha
)

Implementation

Tuple2<int, double> integerInterpolate(int start, int end, double alpha) {
  if (alpha >= 1) {
    return Tuple2(end - 1, 1.0);
  }

  if (alpha <= 0) {
    return Tuple2(start, 0);
  }

  var value = interpolate<double>(start, end, alpha).toInt();
  var residue = ((end - start) * alpha) % 1;

  return Tuple2(value, residue);
}