Static p5_sys::global::curve[][src]

pub static curve: CurveInternalType
Expand description

Draws a curved line on the screen between two points, given as the middle four parameters. The first two parameters are a control point, as if the curve came from this point even though it's not drawn. The last two parameters similarly describe the other control point.

Longer curves can be created by putting a series of curve() functions together or using curveVertex(). An additional function called curveTightness() provides control for the visual quality of the curve. The curve() function is an implementation of Catmull-Rom splines.

Examples

noFill();
stroke(255, 102, 0);
curve(5, 26, 5, 26, 73, 24, 73, 61);
stroke(0);
curve(5, 26, 73, 24, 73, 61, 15, 65);
stroke(255, 102, 0);
curve(73, 24, 73, 61, 15, 65, 15, 65);
// Define the curve points as JavaScript objects
let p1 = { x: 5, y: 26 };
let p2 = { x: 73, y: 24 };
let p3 = { x: 73, y: 61 };
let p4 = { x: 15, y: 65 };
noFill();
stroke(255, 102, 0);
curve(p1.x, p1.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);
stroke(0);
curve(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y);
stroke(255, 102, 0);
curve(p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, p4.x, p4.y);
noFill();
stroke(255, 102, 0);
curve(5, 26, 0, 5, 26, 0, 73, 24, 0, 73, 61, 0);
stroke(0);
curve(5, 26, 0, 73, 24, 0, 73, 61, 0, 15, 65, 0);
stroke(255, 102, 0);
curve(73, 24, 0, 73, 61, 0, 15, 65, 0, 15, 65, 0);

Overloads

x1 x-coordinate for the beginning control point

y1 y-coordinate for the beginning control point

x2 x-coordinate for the first point

y2 y-coordinate for the first point

x3 x-coordinate for the second point

y3 y-coordinate for the second point

x4 x-coordinate for the ending control point

y4 y-coordinate for the ending control point


x1 x-coordinate for the beginning control point

y1 y-coordinate for the beginning control point

z1 z-coordinate for the beginning control point

x2 x-coordinate for the first point

y2 y-coordinate for the first point

z2 z-coordinate for the first point

x3 x-coordinate for the second point

y3 y-coordinate for the second point

z3 z-coordinate for the second point

x4 x-coordinate for the ending control point

y4 y-coordinate for the ending control point

z4 z-coordinate for the ending control point