Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created October 29, 2012 03:04
Show Gist options
  • Save jordanorelli/3971248 to your computer and use it in GitHub Desktop.
Save jordanorelli/3971248 to your computer and use it in GitHub Desktop.
some circles in processing.
Pulse[] pulses = new Pulse[48];
void setup() {
size(640, 480);
background(0);
smooth();
ellipseMode(CENTER);
noFill();
strokeWeight(20);
stroke(255,128);
for(int i = 0; i < pulses.length; i++) {
float x = i * (width / pulses.length);
float t = i * TWO_PI / pulses.length;
pulses[i] = new Pulse(x, height/2.0, 100.0, 400.0, 0.0125, t);
}
}
void draw() {
background(0);
for(int i = 0; i < pulses.length; i++) {
pulses[i].update();
}
}
class Pulse {
float x, y, diameter, minDiameter, maxDiameter, dt, t;
Pulse(float x, float y, float minDiameter, float maxDiameter, float dt, float t) {
this.x = x;
this.y = y;
this.minDiameter = minDiameter;
this.maxDiameter = maxDiameter;
this.dt = dt;
this.diameter = minDiameter;
this.t = t;
}
void update() {
this.t += this.dt;
this.diameter = ((sin(this.t) + 1.0) / 2.0) * (this.maxDiameter - this.minDiameter) + this.minDiameter;
ellipse(this.x, this.y, this.diameter, this.diameter);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment