xxxxxxxxxx
50
let counter = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
}
function draw() {
// Using the counter trick that we did in class. I tried to time this background to ABBA's Dancing Queen.
if(counter%65 == 0) {
light();
light();
}
// Used 15 for the glitter so it'd more or less coincide with a 4/4 beat. The lights should be a little slower; I thought once per second, but that was a little too slow for the beat. Left it 65 for now.
if(counter%15 == 0){
glitter();
glitter();
glitter();
glitter();
glitter();
background(0, 0.5);
glitter();
glitter();
glitter();
glitter();
glitter();
}
counter++;
}
// Made a function for the glitter to more easily adjust the values while playing with it.
function glitter(w, h, d) {
colorMode(HSB);
noStroke();
fill(50, 100, random(100));
ellipse(random(width), random(height), random(5, 10));
}
// Likewise with the light beams.
function light(x1, y1, x2, y2, x3, y3, x4, y4) {
colorMode(HSB);
noStroke();
fill(50, 50, random(90, 100), 0.3);
let R1 = random(windowWidth);
let R2 = random(windowWidth);
quad(R1, 0, R1-(windowWidth/25), 0, R2, windowWidth, R2+(windowWidth/5), windowWidth);
}