curve()
Shape / CurvesDescription
Draws a curved line on the screen (Catmull-Rom spline).
Syntax
void curve(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
Parameters
| Name | Type | Description |
|---|---|---|
| x0 | float | x of beginning control point |
| y0 | float | y of beginning control point |
| x1 | float | x of first point |
| y1 | float | y of first point |
| x2 | float | x of second point |
| y2 | float | y of second point |
| x3 | float | x of ending control point |
| y3 | float | y of ending control point |
Returns
voidRelated
Under the Hood
From Processing.h:
void curve(float,float,float,float,float,float,float,float);
curve((float)x0,(float)y0,(float)x1,(float)y1,
(float)x2,(float)y2,(float)x3,(float)y3);
void curve(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3);
inline void curve(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3){ if(PApplet::g_papplet) PApplet::g_papplet->curve(x0,y0,x1,y1,x2,y2,x3,y3); }
Under the Hood
From Processing.cpp:
void PApplet::curve(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3){
if(!doStroke)return;applyStroke();glLineWidth(strokeW);glBegin(GL_LINE_STRIP);
float s=curveTightnessVal;
for(int i=0;i<=curveDetailVal;i++){
float t=i/(float)curveDetailVal,t2=t*t,t3=t2*t;
float b0=(-s*t3+2*s*t2-s*t)/2.f,b1=((2-s)*t3+(s-3)*t2+1)/2.f;
float b2=((s-2)*t3+(3-2*s)*t2+s*t)/2.f,b3=(s*t3-s*t2)/2.f;
glVertex2f(b0*x0+b1*x1+b2*x2+b3*x3,b0*y0+b1*y1+b2*y2+b3*y3);
}
glEnd();
}