参考 splinePoint()

splinePoint()

Calculates coordinates along a spline curve using interpolation.

splinePoint() calculates coordinates along a spline curve using four points p0, p1, p2, p3. It expects points in the same order as the spline() function. splinePoint() works one axis at a time. Passing the points' x-coordinates will calculate the x-coordinate of a point on the curve. Passing the points' y-coordinates will calculate the y-coordinate of a point on the curve.

The first parameter, a, is the coordinate of point p0.

The second and third parameters, b and c, are the coordinates of points p1 and p2.

The fourth parameter, d, is the coordinate of point p3.

The fifth parameter, t, is the amount to interpolate along the span from p1 to p2. t = 0 is p1, t = 1 is p2, and t = 0.5 is halfway between them.

示例

语法

splinePoint(a, b, c, d, t)

参数

a
Number: coordinate of point p0.
b
Number: coordinate of point p1.
c
Number: coordinate of point p2.
d
Number: coordinate of point p3.
t
Number: amount to interpolate between 0 and 1.

返回值

Number: coordinate of a point on the curve.
Notice any errors or typos? Please let us know. Please feel free to edit src/shape/curves.js and open a pull request!

相关参考