Skip to main content

Path.measureAlong()

The Path.measureAlong() method returns the offset of the given point on this path, as if you measured along this path until you've reached the given point.

note

This method returns (approximately) the same value as this.split(p)[0].length() would.

However, this method is likely faster and you need less handling of special cases. E.g., if the given point is identical to the start of this path, then this method would simply return 0, whereas this.split(p)[0] would be null, requiring you to handle that edge case.

This returns null if the given point doesn't lie on this path.

tip

This method can also be used as an efficient way to check if a point lies on a path.

Signature

number|null path.measureAlong(Point point)

Example

2.43cm 6.07cm 12.15cm 18.21cm 21.85cm

Example of the Path.measureAlong() method