Inspiration Resources Code The Spinning Circles
 

 

Code

import pitaru.sonia_v2_9.*;
import krister.Ess.*;
Channel myChannel;
int MAX = 13;
float angle;
float cosine;
float jitter;
float level;
boolean spinning = false;
int counter = 0;
float[] xx = new float[MAX];
float[] yy = new float[MAX];
color[] colors = new color[MAX];
float[] d = new float[MAX]; // array d
float change = 5;
void setup() {
Ess.start(this);
myChannel=new Channel("spin.wav");
size (500, 500);
background(0);
smooth();
ellipseMode(CENTER);
Sonia.start(this); // Start Sonia engine.
LiveInput.start(256); // Start LiveInput and return 256 FFT frequency bands.
for (int i = 0; i<xx.length; i++) {
xx[i] = random(width);
yy[i] = random(height);
colors[i] = color(random(255), random(255), random(255),
random(40));
d[i] = random(0,2); // array d
}
}
void draw() {
level = LiveInput.getLevel();
//println(level);
fill(0,30);
rect(0,0,width,height);
if (spinning){
noFill();
for (int i=0; i< counter; i++) {
strokeWeight(1);
stroke(colors[i]);
pushMatrix();
translate(xx[i], yy[i]);
rotate(angle);
circle(3,1,d[i]*2*level); // array d
popMatrix();
// if (level > 1.0) {
d[i] = d[i] + 1;//array for d value
}
angle += 0.5;
}
}
void circle(float x,float y,float r) {
if(r>15) {
ellipse(x,y,r,r);
circle(x,y,r/2);
circle(x,y,r/3);
circle(x,y,r/4);
circle(x,y,r/5);
}
}
void mouseDragged() {
for (int i=0; i< counter; i++) {
d[i] = 0;//reset to 0 if it is too large
}
float distance = dist(mouseX,mouseY,width/2,height/2);
if (distance < 50) {
println("center");
for (int i = 0; i<xx.length; i++) {
xx[i] = width/2;
yy[i] = height/2;
}
}
else {
for (int i = 0; i<xx.length; i++) {
xx[i] = random(width);
yy[i] = random(height);
}
}
}
void mousePressed() {
myChannel.play(Ess.FOREVER);
spinning = true;
counter = counter + 1;
if (counter > xx.length-1) {
counter = xx.length-1;
}
xx[counter] = mouseX;
yy[counter] = mouseY;
}
void keyPressed() {
myChannel.stop();
}
public void stop() {
Ess.stop();
super.stop();
}