Vector strokes; Stroke currentStroke; boolean bRecursive; void setup(){ size(720, 450); strokes = new Vector(); // smooth(); } void draw(){ background(0); //smooth(); if(currentStroke != null){ noFill(); strokeWeight(3); stroke(255, 0, 0); pushMatrix(); translate(currentStroke.start.x, currentStroke.start.y); // if(bRecursive) currentStroke.drawWithRecursion(currentStroke); // else // currentStroke.draw(); popMatrix(); } } void mousePressed(){ Stroke new_stroke = new Stroke(); currentStroke = new_stroke; currentStroke.setStart(mouseX, mouseY); oldmouseX = mouseX; oldmouseY = mouseY; bRecursive = false; } int oldmouseX, oldmouseY; void mouseDragged(){ if(dist(mouseX, mouseY, oldmouseX, oldmouseY) > 20){ currentStroke.addPoint(mouseX, mouseY); oldmouseX = mouseX; oldmouseY = mouseY; } } void mouseReleased(){ if(currentStroke != null){ strokes.add(currentStroke); //currentStroke = null; print("added"); } bRecursive = true; } int fileID = 0; void keyPressed(){ if(key == 's'){ save("output"+fileID+".tif"); fileID++; } }