level 1
王家的蛋糕
楼主
import ddf.minim.*;
import ddf.minim.analysis.*;
float m_faudioX = 0.;
float m_faudioY = 0.;
float eRadius;
Minim minim;
VizAudio vizAudio;
float theta = 0;
void setup() {
size(1024, 768, P3D);
minim = new Minim(this);
vizAudio = new VizAudio(minim);
}
void draw() {
background(#6A171D);
fft.forward(music.left);
stroke(255);
translate(50,height-100);
noFill();
beginShape();
stroke(255);
curveVertex(-50,0);
curveVertex(0,0);
for(int i=0;i<480;i+=2){
h=fft.getBand(i)*10;
curveVertex(i,-h);
println(h);
}
endShape();
}
vizAudio.draw();
for (int i = 0; i < 100; i ++) {
pushMatrix();
translate(width/2, height/2);
pushMatrix();
rotate(i*mouseX);
translate(-width/2, -height/2);
float sinValue = map(sin(theta), -1, 1, 0, width);
float cosValue = map(cos(theta), -1, 1, 0, height);
pushMatrix();
translate(sinValue,cosValue);
noFill();
stroke(i*#8E0A0A);
rotateY(theta);
box(400+map(sin(theta), -1, 1, -100, 100));
popMatrix();
popMatrix();
popMatrix();
}
theta += 0.01;
}
2018年06月19日 01点06分
1
import ddf.minim.analysis.*;
float m_faudioX = 0.;
float m_faudioY = 0.;
float eRadius;
Minim minim;
VizAudio vizAudio;
float theta = 0;
void setup() {
size(1024, 768, P3D);
minim = new Minim(this);
vizAudio = new VizAudio(minim);
}
void draw() {
background(#6A171D);
fft.forward(music.left);
stroke(255);
translate(50,height-100);
noFill();
beginShape();
stroke(255);
curveVertex(-50,0);
curveVertex(0,0);
for(int i=0;i<480;i+=2){
h=fft.getBand(i)*10;
curveVertex(i,-h);
println(h);
}
endShape();
}
vizAudio.draw();
for (int i = 0; i < 100; i ++) {
pushMatrix();
translate(width/2, height/2);
pushMatrix();
rotate(i*mouseX);
translate(-width/2, -height/2);
float sinValue = map(sin(theta), -1, 1, 0, width);
float cosValue = map(cos(theta), -1, 1, 0, height);
pushMatrix();
translate(sinValue,cosValue);
noFill();
stroke(i*#8E0A0A);
rotateY(theta);
box(400+map(sin(theta), -1, 1, -100, 100));
popMatrix();
popMatrix();
popMatrix();
}
theta += 0.01;
}