level 1
六元80
楼主
代码在这里
import ddf.minim.*;
Minim minim;
AudioPlayer player;
void loop(){
size(512,200,P3D);
minim = new Minim(this);
player = minim.loadFile("George 姜慧仁 - Something.mp3");
}
import processing.sound.*;
Amplitude amp;
int num = 5000;//点数
float mts = PI/600;//最大theta速度
float r = 100;//圆的半径
int rdtr = 120;//rdt的范围
int rdu = 5;//圆的半径
//**********
PVector v[]=new PVector[num];
boolean mv = true;
boolean mo = true;
color c[] = new color[num];//每个点的颜色
float theta[] = new float[num];//每个点的原始角度
float mtheta[] = new float[num];//将角度转换为数字值
float dtheta[] = new float[num];//theta的速度
float easing[] = new float[num];
int rdt[] = new int[num];//使半径变为shuffle
void setup(){
colorMode(RGB,255,255,255);
size(1500,960);
for (int i =0;i<num-1;i++){
c[i] = color(random(0,255),random(0,255),random(0,255));
v[i] = new PVector(random(width),random(height));
theta[i] = round(random(360));
dtheta[i] = random(mts);
mtheta[i] = theta[i]/180*PI;
rdt[i] = round(random(-rdtr,-rdtr));
easing[i] = random(0.02,0.3);
}
frameRate(60);
minim=new Minim(this);
player.minim();
amp=new Amplitude(this);
amp.input(mic);
}
void draw(){
fill(0,0,0,25);
rect(0,0,width,height);
pushMatrix();
noStroke();
r=map(amp.analyze(),0,0.1,100,width);
if (mv){
if (mo){
for (int i = 0;i<num-1;i++){
mtheta[i] += dtheta[i];
v[i].lerp(mouseX+cos(mtheta[i])*(rdt[i]+r),mouseY+sin(mtheta[i])*(rdt[i]+r),0,easing[i]);
fill(c[i]);
ellipse(v[i].x,v[i].y,rdu,rdu);
}
}
if (!mo){
for (int i = 0;i<num-1;i++){
v[i].lerp(mouseX+cos(mtheta[i])*(rdt[i]+r),mouseY+sin(mtheta[i])*(rdt[i]+r),0,easing[i]);
fill(c[i]);
ellipse(v[i].x,v[i].y,rdu,rdu);
}
}
}
if (!mv){
if (mo){
for (int i = 0;i<num-1;i++){
mtheta[i] += dtheta[i];
v[i].lerp(mouseX+cos(mtheta[i])*rdt[i],mouseY+sin(mtheta[i])*rdt[i],0,easing[i]);
fill(c[i]);
ellipse(v[i].x,v[i].y,rdu,rdu);
}
}
if (!mo){
for (int i = 0;i<num-1;i++){
v[i].lerp(mouseX+cos(mtheta[i])*rdt[i],mouseY+sin(mtheta[i])*rdt[i],0,easing[i]);
fill(c[i]);
ellipse(v[i].x,v[i].y,rdu,rdu);
}
}
}
popMatrix();
fill(0);
rect(0,0,width,15);
fill(255);
textAlign(LEFT,TOP);
text("r = "+r,0,0);
text("fps = "+round(frameRate),40,0);
if (mv){
fill(255,0,0);
text("Running",100,0);
}
if(!mv){
text("Static",100,0);
}
if(mo){
fill(255,0,0);
text("motion",150,0);
}
if (!mo){
fill(255);
text("stop",150,0);
}
}
void mousePressed(){
}
void keyPressed(){
if(key == 's'||key == 'S'){
mo =!mo;
}
}
void mouseWheel(MouseEvent event){
float e = event.getCount();
if (e == -1) r+=10;
if (e == 1) r-=10;
}
2021年12月13日 03点12分
1
import ddf.minim.*;
Minim minim;
AudioPlayer player;
void loop(){
size(512,200,P3D);
minim = new Minim(this);
player = minim.loadFile("George 姜慧仁 - Something.mp3");
}
import processing.sound.*;
Amplitude amp;
int num = 5000;//点数
float mts = PI/600;//最大theta速度
float r = 100;//圆的半径
int rdtr = 120;//rdt的范围
int rdu = 5;//圆的半径
//**********
PVector v[]=new PVector[num];
boolean mv = true;
boolean mo = true;
color c[] = new color[num];//每个点的颜色
float theta[] = new float[num];//每个点的原始角度
float mtheta[] = new float[num];//将角度转换为数字值
float dtheta[] = new float[num];//theta的速度
float easing[] = new float[num];
int rdt[] = new int[num];//使半径变为shuffle
void setup(){
colorMode(RGB,255,255,255);
size(1500,960);
for (int i =0;i<num-1;i++){
c[i] = color(random(0,255),random(0,255),random(0,255));
v[i] = new PVector(random(width),random(height));
theta[i] = round(random(360));
dtheta[i] = random(mts);
mtheta[i] = theta[i]/180*PI;
rdt[i] = round(random(-rdtr,-rdtr));
easing[i] = random(0.02,0.3);
}
frameRate(60);
minim=new Minim(this);
player.minim();
amp=new Amplitude(this);
amp.input(mic);
}
void draw(){
fill(0,0,0,25);
rect(0,0,width,height);
pushMatrix();
noStroke();
r=map(amp.analyze(),0,0.1,100,width);
if (mv){
if (mo){
for (int i = 0;i<num-1;i++){
mtheta[i] += dtheta[i];
v[i].lerp(mouseX+cos(mtheta[i])*(rdt[i]+r),mouseY+sin(mtheta[i])*(rdt[i]+r),0,easing[i]);
fill(c[i]);
ellipse(v[i].x,v[i].y,rdu,rdu);
}
}
if (!mo){
for (int i = 0;i<num-1;i++){
v[i].lerp(mouseX+cos(mtheta[i])*(rdt[i]+r),mouseY+sin(mtheta[i])*(rdt[i]+r),0,easing[i]);
fill(c[i]);
ellipse(v[i].x,v[i].y,rdu,rdu);
}
}
}
if (!mv){
if (mo){
for (int i = 0;i<num-1;i++){
mtheta[i] += dtheta[i];
v[i].lerp(mouseX+cos(mtheta[i])*rdt[i],mouseY+sin(mtheta[i])*rdt[i],0,easing[i]);
fill(c[i]);
ellipse(v[i].x,v[i].y,rdu,rdu);
}
}
if (!mo){
for (int i = 0;i<num-1;i++){
v[i].lerp(mouseX+cos(mtheta[i])*rdt[i],mouseY+sin(mtheta[i])*rdt[i],0,easing[i]);
fill(c[i]);
ellipse(v[i].x,v[i].y,rdu,rdu);
}
}
}
popMatrix();
fill(0);
rect(0,0,width,15);
fill(255);
textAlign(LEFT,TOP);
text("r = "+r,0,0);
text("fps = "+round(frameRate),40,0);
if (mv){
fill(255,0,0);
text("Running",100,0);
}
if(!mv){
text("Static",100,0);
}
if(mo){
fill(255,0,0);
text("motion",150,0);
}
if (!mo){
fill(255);
text("stop",150,0);
}
}
void mousePressed(){
}
void keyPressed(){
if(key == 's'||key == 'S'){
mo =!mo;
}
}
void mouseWheel(MouseEvent event){
float e = event.getCount();
if (e == -1) r+=10;
if (e == 1) r-=10;
}