transformInternal method

  1. @override
Offset transformInternal(
  1. double t
)
override

Returns the value of the curve at point t.

The given parametric value t will be between 0.0 and 1.0, inclusive.

Implementation

@override
Offset transformInternal(double t) {
  _initializeIfNeeded();
  final double length = _cubicSegments.length.toDouble();
  final double position;
  final double localT;
  final int index;
  if (t < 1.0) {
    position = t * length;
    localT = position % 1.0;
    index = position.floor();
  } else {
    position = length;
    localT = 1.0;
    index = _cubicSegments.length - 1;
  }
  final List<Offset> cubicControlPoints = _cubicSegments[index];
  final double localT2 = localT * localT;
  return cubicControlPoints[0] * localT2 * localT
       + cubicControlPoints[1] * localT2
       + cubicControlPoints[2] * localT
       + cubicControlPoints[3];
}