绘制使用 Catmull-Rom 样条的曲线。
样条曲线可以形成轻微倾斜的形状和曲线。它们就像连接到一组点的电缆。样条曲线由两个锚点和两个控制点定义。
前两个参数 x1 和 y1 设置第一个控制点。这个点不会被绘制,可以被认为是曲线的起点。
接下来的四个参数 x2, y2, x3,和 y3,设置两个锚点。锚点是曲线可见部分的起点和终点。
第七个和第八个参数 ,x4 和 y4 设置最后一个控制点。这个点不会被绘制,可以被认为是曲线的终点。
样条曲线也可以在 3D 中使用 WebGL 模式绘制。curve() 的 3D 版本有十二个参数,因为每个点都有 x、y 和 z 坐标。
示例
语法
curve(x1, y1, x2, y2, x3, y3, x4, y4)
curve(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4)
参数
x-coordinate of the first control point.
y-coordinate of the first control point.
x-coordinate of the first anchor point.
y-coordinate of the first anchor point.
x-coordinate of the second anchor point.
y-coordinate of the second anchor point.
x-coordinate of the second control point.
y-coordinate of the second control point.
z-coordinate of the first control point.
z-coordinate of the first anchor point.
z-coordinate of the second anchor point.
z-coordinate of the second control point.