looks like your point 5 ( as is at point1 )
is what you have to do to close a rectangle, good,
but do it in the function and not in the call
int x = 100, y = 100, w = 40, h = 80;
boolean showP = false;
void setup() {
size(300,300);
noFill();
strokeWeight(3);
}
void draw() {
background(200,200,0);
curves(x,y,x+w,y,x+w,y+h,x,y+h);
}
void curves(int _x1, int _y1, int _x2, int _y2, int _x3, int _y3, int _x4, int _y4) {
beginShape();
curveVertex(_x4, _y4); // control point
curveVertex(_x1, _y1);
if ( showP ) circle(_x1, _y1,3);
curveVertex(_x2, _y2);
if ( showP ) circle(_x2, _y2,3);
curveVertex(_x3, _y3);
if ( showP ) circle(_x3, _y3,3);
curveVertex(_x4, _y4);
if ( showP ) circle(_x4, _y4,3);
curveVertex(_x1, _y1);
curveVertex(_x2, _y2); // control point
endShape();
}
or see it this way:
int x = 100,y = 100,w = 40,h = 80;
boolean showP = false;
void setup() {
size(300,300);
noFill();
strokeWeight(3);
}
void draw() {
background(200,200,0);
curve_vertex_rect(x,y,w,h);
}
void curve_vertex_rect(int _x, int _y, int _w, int _h) {
int _x1 = _x;
int _y1 = _y;
int _x2 = _x1+_w;
int _y2 = _y1;
int _x3 = _x1+_w;
int _y3 = _y1+_h;
int _x4 = _x1;
int _y4 = _y1+_h;
beginShape();
curveVertex(_x4, _y4); // control point
curveVertex(_x1, _y1);
if ( showP ) circle(_x1, _y1,3);
curveVertex(_x2, _y2);
if ( showP ) circle(_x2, _y2,3);
curveVertex(_x3, _y3);
if ( showP ) circle(_x3, _y3,3);
curveVertex(_x4, _y4);
if ( showP ) circle(_x4, _y4,3);
curveVertex(_x1, _y1);
curveVertex(_x2, _y2); // control point
endShape();
}