getTangentForOffset method

Tangent getTangentForOffset (double distance)

Computes the position of hte current contour at the given offset, and the angle of the path at that point.

For example, calling this method with a distance of 1.41 for a line from 0.0,0.0 to 2.0,2.0 would give a point 1.0,1.0 and the angle 45 degrees (but in radians).

Returns null if the contour has zero length.

The distance is clamped to the length of the current contour.

Implementation

Tangent getTangentForOffset(double distance) {
  final Float32List posTan = _getPosTan(distance);
  // first entry == 0 indicates that Skia returned false
  if (posTan[0] == 0.0) {
    return null;
  } else {
    return new Tangent(
      new Offset(posTan[1], posTan[2]),
      new Offset(posTan[3], posTan[4])
    );
  }
}