Processing Forum
/* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/10475*@* */ /* !do not delete the line above, required for linking your tweak if you re-upload */ int elapsedFrames = 0; ArrayList points = new ArrayList(); boolean drawing = false; void setup() { smooth(); size(1280, 400); background(0); } void draw() { if (drawing == true) { PVector pos = new PVector(); pos.x = mouseX; pos.y = mouseY; PVector vel = new PVector(); vel.x = (0); vel.y = (0); Point punt = new Point(pos, vel, 250); points.add(punt); } for (int i = 0; i < points.size(); i++) { Point localPoint = (Point) points.get(i); if (localPoint.isDead == true) { points.remove(i); } localPoint.update(); localPoint.draw(); } elapsedFrames++; } void keyPressed() { if (key == ' ') { for (int i = 0; i < points.size(); i++) { Point localPoint = (Point) points.get(i); localPoint.isDead = true; } noStroke(); fill(0); rect(0, 0, width, height); } } void mousePressed() { drawing = true; } void mouseReleased() { drawing = false; } class Point { PVector pos, vel, noiseVec; float noiseFloat, lifeTime, age; boolean isDead; public Point(PVector _pos, PVector _vel, float _lifeTime) { pos = _pos; vel = _vel; lifeTime = _lifeTime; age = 0; isDead = false; noiseVec = new PVector(); } void update() { noiseFloat = noise(pos.x * 0.0025, pos.y * 0.0025, elapsedFrames * 0.0001) *10; noiseVec.x = cos(((noiseFloat - 0.3) * HALF_PI) * -20); noiseVec.y = sin(((noiseFloat - 0.3) * HALF_PI) * -20); vel.add(noiseVec); vel.div(5.5); pos.add(vel); pos.sub(noiseVec); if (1.0-(age/lifeTime) == 0) { isDead = true; points.remove(0); } if (pos.x < 0 || pos.x &rt; width || pos.y < 0 || pos.y &rt; height) { isDead = true; } age++; } void draw() { //fill(255, 50, 255); noStroke(); stroke (random (0, 100), random (0, 100), random (255, 0), 35 ); smooth(); ellipse(pos.x, pos.y, 1/(age), 1/(age)); fill (random(0, 10)); smooth(); //saveFrame("seq-####.tga"); } };