Mudpile m = null; void setup(){ size(500,500); background(150,150,20); frameRate(10); strokeWeight(4); stroke(125,125,15); fill(150,150,20); } void mousePressed(){ if(m == null){ m = new Mudpile(mouseX,mouseY); } } float ANGSTEP = .08; float VARMUL = .025; float SHRINK = 10; float CENTERMOVE = 2; void draw(){ if(m != null) { if(!m.draw()) m = null; } } class Mudpile{ float cx = 250; float cy = 250; float cxs = 0,cys = 0; float baser = random(50,150); Mudpile(float sx, float sy){ cx = sx; cy = sy; } boolean draw(){ if(baser <= 0) return false; pushMatrix(); translate(cx,cy); if(cx < mouseX) cxs+= CENTERMOVE; else cxs-=CENTERMOVE; if(cy < mouseY) cys+=CENTERMOVE; else cys-=CENTERMOVE; cx += cxs; cy += cys; beginShape(); float first = baser + random(-15,15); vertex(first * cos(0),first * sin(0)); for(float a = ANGSTEP; a < PI*2; a += ANGSTEP){ float r = baser + random(-baser * VARMUL, baser * VARMUL); vertex(r * cos(a),r * sin(a)); } vertex(first * cos(0),first * sin(0)); if(!mousePressed) baser -= SHRINK; endShape(); popMatrix(); return true; } }