Draws a curve using a Catmull-Rom spline.
Spline curves can form shapes and curves that slope gently. They’re like cables that are attached to a set of points. By default (ends: INCLUDE
), the curve passes through all four points you provide, in order p0(x1,y1)
-> p1(x2,y2)
-> p2(x3,y3)
-> p3(x4,y4)
. Think of them as points on a curve. If you switch to ends: EXCLUDE
, p0 and p3 act like control points and only the middle span p1->p2
is drawn.
Spline curves can also be drawn in 3D using WebGL mode. The 3D version of spline()
has twelve arguments because each point has x-, y-, and z-coordinates.
Examples
Syntax
spline(x1, y1, x2, y2, x3, y3, x4, y4)
spline(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4)
Parameters
x1
Number: x-coordinate of point p0.
y1
Number: y-coordinate of point p0.
x2
Number: x-coordinate of point p1.
y2
Number: y-coordinate of point p1.
x3
Number: x-coordinate of point p2.
y3
Number: y-coordinate of point p2.
x4
Number: x-coordinate of point p3.
y4
Number: y-coordinate of point p3.
z1
Number: z-coordinate of point p0.
z2
Number: z-coordinate of point p1.
z3
Number: z-coordinate of point p2.
z4
Number: z-coordinate of point p3.
Notice any errors or typos? Please let us know. Please feel free to edit src/shape/curves.js and open a pull request!