class Ripple { float x, y; float max_r, r; float step; boolean FINISHED = false; float max_brightness; float thickness; Ripple(float x, float y, float r) { this.x = x; this.y = y; this.max_r = r; this.r = 0; step = random(0.3, 0.8); max_brightness = 210; thickness = random(1, 5); } /***************************** * Update object state */ void update() { if (r <= max_r) { // If r is smaller than max radius r = r + (step * 2); // then keep expanding, } else { FINISHED = true; // otherwise put the object into dead state. } } /***************************** * Draw the ripple */ void display() { noFill(); stroke(0, max_brightness, max_brightness, 255 * (max_r - r) / max_r); strokeWeight(1); ellipse(this.x, this.y, this.r, this.r); } /***************************** * Return object state */ boolean finished() { return FINISHED; } }