xxxxxxxxxx
31
function setup() {
createCanvas(windowWidth, windowHeight);
initialize();
}
function initialize() {
background(0);
noFill();
stroke(255);
strokeWeight(2);
let diameter = min(width, height); //sets the diameter to which ever is smaller, the height or width, and in this case it's the width
drawCircle(width / 2, height / 2, diameter); //draws a circle based in the center of the screen with the diameter set in the drawCircle function below
// console.log(diameter, width, height);
}
function drawCircle(x, y, d) {
circle(x, y, d); //creates a circle at the x, y, and d parameters set in the function above
// console.log(d); //original diameter is the width of the screen
let new_d = d / 2; //creates a new diameter by dividing the previous diameter by 2
if (new_d >= 4) { //creates a new circle and keeps diving the diameter until the diameter gets below 4
drawCircle(x, y, new_d); //draws a new circle with the new diameter
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
initialize();
}