Random red dots

The link is here. Just click on the canvas to see what happens. May not work on mobile.

The code:

function setup() {
  createCanvas(windowWidth, windowHeight);
  noCursor()
}

function draw() {
  //dark background with transparency
  background(0, 0, 35, 25);
  
  //blinking stars object with three properties
  var galaxy = {
    locationX: random(width),//anywhere in width
    locationY: random(height),//anywhere in height
    size: random(1, 6)//any size between 1 and 6
  }
  
  
  fill(255, 0, 0)
  
  if(mouseIsPressed){
  background(255, 0, 0)
  fill(0, 0, 255)
  }
  ellipse(galaxy.locationX, galaxy.locationY, galaxy.size, galaxy.size)
  
  
}

Leave a Reply