Skip to main content

utils.curveParameterFromPoint()

The utils.curveParameterFromPoint() function calculates where the point check lies on a curve described by points start, cp1, cp2, and end.

For example a return value of 0 indicates that the given point is the start of the curve, a return value of 1 indicated that the given point is identical to the end of the curve.

A return value of 0.5 indicates that the start point and the first control point had the same influence as the end point and the second control point, to create the checked point, but this doesn't necessarily mean that the point lies exactly half-way on the curve.

This method returns false if the point isn't (approximately) located on the curve.

Signature

number|false utils.curveParameterFromPoint(
Point start,
Point cp1,
Point cp2,
Point end,
Point check
)

Example

0 0.18 0.39 0.61 0.82 1

A Utils.curveParameterFromPoint() example

Notes

Keep in mind that calculations with Bézier curves are often approximations.

This method is mostly used as internal building block for methods like utils.pointOnCurve(), Path.split() or Path.angleAt() and probably is not very relevant for direct usage from pattern code.