var count = 200; var x = 0; var posX = []; var posX2 = []; var posY = []; var posY2 = []; var speedX = []; var speedX2 = []; var speedY = []; var speedY2 = []; var sizeW = []; var sizeH = []; var colors = []; let xoff = 0.0; function setup() { createCanvas(900,900); // frameRate(30); // background(255); noStroke(); for (var i=0; i < count; i++) { posX[i] = width/2; posY[i] = height/2; posX2[i] = width/4; posY2[i] = height/4; speedX[i] = random(-5, 5); speedY[i] = random(-5, 5); speedX2[i] = random(-15, 15); speedY2[i] = random(-15, 15); sizeW[i] = random(20, 25); sizeH[i] = random(20, 100); colors[i] = (random(0, 255)); } noiseSeed(99); stroke(0, 500); } function draw() { fill(100,50); rect(0, 0, width, height); console.log("hi"); for (var i = 0; i < count; i++) { // //update all positions posX[i] += speedX[i]; posY[i] += speedY[i]; posX2[i] += speedX2[i]; posY2[i] += speedY2[i]; // //draw all balls fill(colors[i], random(colors[i]), random(255)); // fill(150, 200, 75); rect(posX[i], posY[i], sizeW[i], sizeW[i]); // rect(10, 10, 20, 20); ellipse(posX2[i], posY2[i], sizeW[i], sizeW[i]); // tint(0, 153, 204, 126); //check boundaries for all balls if (posX[i] < 40+sizeW[i]/2 || posX[i] > (width-40)-sizeW[i]/2 ) { speedX[i] = -speedX[i]; } if (posY[i] < 40+sizeW[i]/2 || posY[i] > (height-40)-sizeW[i]/2) { speedY[i] = -speedY[i]; } if (posX2[i] < 40+sizeW[i]/2 || posX2[i] > (width-40)-sizeW[i]/2 ) { speedX2[i] = -speedX2[i]; } if (posY2[i] < 40+sizeW[i]/2 || posY2[i] > (height-40)-sizeW[i]/2) { speedY2[i] = -speedY2[i]; } } strokeCap(ROUND); xoff = xoff + .01; let n = noise(xoff) * width; line(n, 0, n, height); }