getPoint method

  1. @override
dynamic getPoint(
  1. num t,
  2. dynamic optionalTarget
)
override

Implementation

@override
getPoint(t, optionalTarget) {
  var d = t * getLength();
  var curveLengths = getCurveLengths();
  var i = 0;

  // To think about boundaries points.

  while (i < curveLengths.length) {
    if (curveLengths[i] >= d) {
      var diff = curveLengths[i] - d;
      var curve = curves[i];

      var segmentLength = curve.getLength();
      var u = segmentLength == 0 ? 0 : 1 - diff / segmentLength;

      return curve.getPointAt(u, optionalTarget);
    }

    i++;
  }

  return null;

  // loop where sum != 0, sum > d , sum+1 <d
}