transform method

  1. @override
double transform(
  1. double t
)
override

Returns the value of the curve at point t.

This function must ensure the following:

  • The value of t must be between 0.0 and 1.0
  • Values of t=0.0 and t=1.0 must be mapped to 0.0 and 1.0, respectively.

It is recommended that subclasses override transformInternal instead of this function, as the above cases are already handled in the default implementation of transform, which delegates the remaining logic to transformInternal.

Implementation

@override
double transform(double t) {
  assert(t >= 0.0 && t <= 1.0);
  assert(split >= 0.0 && split <= 1.0);

  if (t == 0.0 || t == 1.0) {
    return t;
  }

  if (t == split) {
    return split;
  }

  if (t < split) {
    final double curveProgress = t / split;
    final double transformed = beginCurve.transform(curveProgress);
    return lerpDouble(0, split, transformed)!;
  } else {
    final double curveProgress = (t - split) / (1 - split);
    final double transformed = endCurve.transform(curveProgress);
    return lerpDouble(split, 1, transformed)!;
  }
}