I am new to processing and was assigned in class to create a bezier curve that makes one of the control points mouseX and mouseY along with some other necessary shapes needed for the assignment. Whenever I hit run, however, the control point I set to mouseX and mouseY automatically starts at the top left corner instead of where my mouse currently is on the screen. I have attached an image of the run window and and this is my code:
// https://processing.org/reference/bezier_.html
// https://discourse.processing.org/t/how-to-make-a-bezier-curver-not-start-at-top-left-corner-when-using-mousex-mousey-as-the-initial-anchor-point/13912/2
// the anchor points define begin and end of the bezier curve
// the control points define the starting angle of the curve at the anchor points
void setup() {
size(800, 800);
noFill();
strokeWeight(5);
}
PVector a1 = new PVector(300,300,0);
PVector c1 = new PVector( 50,400,0);
PVector c2 = new PVector(350,400,0);
PVector a2 = new PVector(350,450,0);
void draw() {
background(200,200,0);
c2.set(mouseX,mouseY,0);
stroke(175, 238, 218);
line(a1.x,a1.y,c1.x,c1.y);
line(c2.x,c2.y,a2.x,a2.y);
stroke(200, 0, 0);
circle(c2.x,c2.y,5);
bezier(a1.x,a1.y,c1.x,c1.y,c2.x,c2.y,a2.x,a2.y);
}
It’s not so much as choosing an anchor point or control point as the mouseX and mouseY, I just wanted to know if there was a way to prevent the shape from shooting up to the top left corner. Even if I make a control point the mouseX and mouseY instead of an anchor point, the curve starts at an upper left angle. I want the curve to start static, and then move as my mouse touches the window canvas. Does this make sense?