How do I create interactive Spline curve?
in
Programming Questions
•
2 years ago
Hello I am trying to write a simple function which allows you to create Spline curve by clicking the mouse. I have some basics in OOP but I am new to processing. here is my source code (which doesn't work :( )
I also need to store the information about the spline, no matter how many times the user clicks (that's why I am using array list, but I'm affraid it only stores objects not primitives :( ) and of course RMB closes the spline :)
Has anyone some Idea how to make it work? I will be really grateful :)
- void setup()
{
size(300, 200);
background(255);
smooth();
}
void draw() {
Lasso lasso1 = new Lasso();
lasso1.createLasso();
}
class Lasso {
ArrayList points;
Lasso(){
this.points = new ArrayList();
}
void createLasso(){
noFill();
stroke(0);
beginShape();
if(mousePressed && (mouseButton == LEFT)) {
points.add(mouseX);
points.add(mouseY);
curveVertex(mouseX,mouseY);
}
if(mousePressed && (mouseButton == RIGHT)) {
endShape();
}
}
}
I also need to store the information about the spline, no matter how many times the user clicks (that's why I am using array list, but I'm affraid it only stores objects not primitives :( ) and of course RMB closes the spline :)
Has anyone some Idea how to make it work? I will be really grateful :)
2