ArrayList<PVector> history = new ArrayList<PVector>();
void setup() {
size(400,400);
for(int i = 0; i<2; i++) {
PVector point = new PVector(mouseX,mouseY);
history.add(point);
}
}
void draw() {
// background(255);
fill(0);
//ellipse(mouseX,mouseY,20,20);
strokeWeight(2);
float x = mouseX; // replace with portValues[0]
float y = mouseY; // replace with portValues[1]
PVector point = new PVector(x,y);
history.add(point);
PVector newPt = history.get(history.size()-1);
PVector oldPt = history.get(history.size()-2);
line(oldPt.x,oldPt.y,newPt.x,newPt.y);
//line(pmouseX,pmouseY,mouseX,mouseY);
}