xxxxxxxxxx
65
//slowly change NY to Moscow
let NY;
let Mos;
let song;
let amp;
let fft;
let notAnimating = true;
function preload() {
NY = loadImage("NY.jpg");
Mos = loadImage("MOS.jpg");
song = loadSound ("song.mp3");
}
function setup() {
createCanvas(400, 400);
NY.resize(400,400);
Mos.resize(400,400);
background(Mos);
song.play();
amp = new p5.Amplitude();
fft = new p5.FFT();
fft.setInput(song);
}
function draw() {
if (mouseIsPressed) {
swapImage(NY);
notAnimating = false;
}else{
if(!notAnimating){
swapImage(Mos);
}
}
let level = amp.getLevel();
let level2 = amp.getLevel();
level = map(level, 0, 0.3, 0, 50);
stroke(0);
fill(0);
ellipse(100, 160, level);
}
function swapImage(destination){
for (i = 0; i < 1000; i++) {
let x = random (width);
let y = random (height);
let c = destination.get(x,y);
stroke(c);
line(x,y, x, y);
noStroke();
fill(c);
ellipse (x, y, 2, 2);
}
}