path.pointAtLength(length [, opt])

Return a point on the path that lies length away from the beginning of the path.

If negative length is provided, the algorithm starts looking from the end of the path. If length is higher than path length, the closest visible path endpoint is returned instead. Invisible segments (e.g. Moveto segments) have no length and are therefore skipped by the algorithm. If the path contains no visible segments, the end point of the last segment is returned. If the path has no segments at all, null is returned.

One visible segment is identified which contains the point at length. Finding the desired point is straightforward for linear segments (see line.pointAtLength() for reference). Finding the desired point in curved segments is more complex, as illustrated by the curve.pointAtLength() function.

The opt argument is optional. Two properties may be specified, opt.precision and opt.segmentSubdivisions, which determine maximum error allowed in pointAtLength calculations for curved segments (default precision is 3; this corresponds to maximum observed error of 0.1%). The opt.segmentSubdivisions property is an array of individual segments' subdivision arrays. The path.getSegmentSubdivisions() function may be used to obtain the segmentSubdivisions array. The opt.precision property is still necessary, however; it determines the precision of the point search algorithm in curved segments.