float MID; void keyPressed() { if(key == ' ') reset();} void reset(){ // lines = new ArrayList(); background(255); line(MID,0,MID,height); currentLine = null; spinningLine = null; } //ArrayList lines = new ArrayList(); void setup(){ size(500,500); MID = 250; stroke(0,20); reset(); } Line currentLine; Line spinningLine; void mousePressed(){ currentLine = new Line(mouseX,mouseY); spinningLine = null; } void mouseDragged(){ currentLine.addPoint(mouseX,mouseY); } void mouseReleased(){ if(currentLine == null) return; // lines.add(currentLine); spinningLine = currentLine; currentLine = null; } void draw(){ if(currentLine != null) currentLine.draw(); if(spinningLine != null) { spinningLine.move(); spinningLine.draw(); } /*for(Line n : lines){ n.move(); n.draw(); } */ } class Line { Point start; float a = -PI; ArrayList tail = new ArrayList(); Line(float px, float py){ start = new Point(px,py); } void addPoint(float x, float y){ tail.add(new Point(x,y)); } void move(){ a += PI/64; } void adjust(Point p){ if(p.x > width / 2) p.xs-= 1; if(p.x < width / 2) p.xs+= 1; p.x += p.xs; } void draw(){ Point last = reangle(start); for(Point p : tail){ Point current = reangle(p); line(last.x,last.y,current.x,current.y); last = current; } } Point reangle(Point p){ Point newPoint = new Point( 250 +( (250 - p.x) * cos(a)),p.y); return newPoint; } } class Point{ float x,y,xs,ys; Point(float px, float py){ x = px; y = py; } }