Animate the nodes
in
Programming Questions
•
3 months ago
I wrote this in processing. I wanna animate the whole structure as the mouse is being dragged any help? I'm still a begineer at this. Maxim is only for sound
ArrayList network = new ArrayList();
Maxim maxim;
AudioPlayer player;
AudioPlayer player2;
void setup(){
background(0);
size(400,400);
smooth();
maxim = new Maxim(this);
player = maxim.loadFile("atmos1.wav");
player.setLooping(true);
player2 = maxim.loadFile("bells.wav");
player2.setLooping(true);
player.volume(0.25);
}
void draw(){
stroke(200,random(200,500),random(100,200),20);
}
void mouseDragged(){
player.play();
player2.play();
PVector nodes = new PVector(mouseX,mouseY);
network.add(nodes);
for(int i = 0; i<network.size(); i++){
PVector li = (PVector) network.get(i);
float distance = nodes.dist(li);
if (distance < 50){
line(li.x,li.y,nodes.x,nodes.y);
//ellipse(nodes.x,li.y,2,2);
}
if (distance < 30){
ellipse(nodes.x,nodes.y,2,2);
}
player.setFilter((float) mouseY/height*5000,mouseX / width);
player2.setFilter((float) mouseY/height*5000,mouseX / width);
player2.ramp(1.,1000);
player2.speed((float) mouseX/width/2);
}
}
1