boolean virgin = true; ArrayList flowers = new ArrayList(); Flower f = new Flower(250,250); void setup(){ size(500,500); background(100,200,100); smooth(); frameRate(30); textFont(createFont("",14)); } void draw(){ background(100,200,100); /*if(virgin) { textAlign(LEFT); stroke(0);fill(0); text("an april visual haiku",100,200); text("for amber",100,220); textAlign(RIGHT); text("mouse click anywhere",400,260); text("space resets",400,280); return; }*/ for(Flower f : flowers){ f.update(); f.draw(); } if(addFlower){ flowers.add(new Flower(mouseX,mouseY)); addFlower = false; } } boolean addFlower; void mousePressed(){ virgin = false; addFlower = true; } void keyPressed(){ if(key == ' '){ flowers = new ArrayList(); } } class Flower { float x,y; float dis = 500; float ang = 0.0; float as; boolean spinning = false; Flower(float x, float y) { this.x = x; this.y = y; } void update(){ if(!spinning){ dis *= .6; if(dis < 8) { dis = 8; spinning = true; } } else { ang += as; } } void draw(){ strokeWeight(2); stroke(0); pushMatrix(); translate(x,y); float offx=0, offy=0; if(spinning){ float oa = atan2(mouseY-y,mouseX-x); float d = dist(mouseX,mouseY,x,y); d = constrain(d,0,20); offx = d*cos(oa); offy = d*sin(oa); as = -1 + (offx / 20.0); translate(offx,offy); } stroke(0,100,0); line(0,0,-offx,-offy); for(int i = 1; i <= 6; i++){ pushMatrix(); float a = ang+i*(PI/3.0); rotate(a); translate(dis,0); stroke(0); fill(240,200,80); ellipse(0,0,10,10); popMatrix(); } fill(80,80,200); stroke(0); ellipse(0,0,10,10); popMatrix(); } }