interpolate<T extends Comparable> function

Comparable interpolate <T extends Comparable>(
  1. T t,
  2. {T other,
  3. double skew: 0.5}
)

Implementation

Comparable interpolate<T extends Comparable>(T t,
    {T other, double skew = 0.5}) {
  final double aUnits = measureFnForType(t.runtimeType)(t);
  final double bUnits =
      other == null ? 0 : measureFnForType(other.runtimeType)(other);

  final T smaller = aUnits < bUnits ? t : other;
  final units = (aUnits - bUnits).abs() * skew;

  if (t is DateTime) {
    return (smaller as DateTime).add(Duration(milliseconds: units.toInt()));
  } else if (t is num) {
    return (smaller as num) + units;
  } else {
    throw UnimplementedError('interpolation not implemented for type $T');
  }
}