Making a whole shape with 2 bezierVertex curves
in
Programming Questions
•
6 months ago
Hi,
With the below code, how do I relate the curve variables to the positions of the two control points, so that I avoid that the shape turns into a cross (breaks in the middle)?
void setup() {
size(300, 300);
noStroke();
smooth();
}
void draw() {
// fill(0, 12); // Make the shape blur onto the screen.
background(0); // Animate without blur
blob(mouseX, mouseY, 150, 150);
}
void blob(int p1X, int p1Y, int p2X, int p2Y) { // p1X = control point x axis ...
pushMatrix();
translate(0, 0); // move the position of the entire shape
// scale(size); // scale to size
beginShape(); // draw the blob
vertex(p1X, p1Y); // Set the first anchor point and let it be the same as the first bezier
bezierVertex(80, 0, 80, 75, p2X, p2Y);
bezierVertex(40, p1X*2, 60, 25, p1X, p1Y);
endShape();
popMatrix();
}
1