Millions of rectangles with a little bit of blue

The link is here.

//var bubbles;
//var bubbles1;
let bubbles = [];

function setup() {
  createCanvas(400, 400);
  for(var i = 0; i < 500; i++){
    let x = random(width);
    let y = random(height);
    bubbles[i] = new Bubble(x, y, 50, 50);
  }
  
}

function draw() {
  background(255);
  for(var i = 0; i < bubbles.length; i++){
    bubbles[i].move();
    bubbles[i].show();
  }
}


class Bubble {
  constructor(x, y, size1, size2){
    this.x = x;
    this.y = y;
    this.size1 = size1;
    this.size2 = size2;
  }
  
  move(){
    
    this.x = this.x + random(-5, 5)
    this.y = this.y + random(-5, 5)
  }
  
  show(){
    fill(0, 0, 255, 10);
    stroke('black')
    //noStroke()
    rect(this.x, this.y, this.size1, this.size2)
  }
}

Leave a Reply