xxxxxxxxxx
60
let step = 1;
let stepInc = 1;
let diagonal;
let diagonalRoot;
function setup() {
createCanvas(400, 400);
diagonal = sqrt(2 * pow(max(width, height), 2));
diagonalRoot = sqrt(diagonal);
noFill();
stroke(0);
}
function draw() {
background(220);
translate(width / 2, height / 2);
let p = step * step;
drawStep(p);
drawSmallerSteps(p / 2);
drawLargerSteps(p * 2);
step = step + stepInc;
if (step > diagonalRoot){
step = 1;
}
}
function drawStep(p){
//stroke(255, 0, 0);
ellipse(0, 0, p);
}
function drawSmallerSteps(ps){
if (ps < 1){
return;
}
//stroke(0, 255, 0);
ellipse(0, 0, ps);
drawSmallerSteps(ps / 2);
}
function drawLargerSteps(pl){
console.log(pl);
if (pl > diagonal){
return;
}
//stroke(0, 0, 255);
ellipse(0, 0, pl);
drawLargerSteps(pl * 2);
}