xxxxxxxxxx
let depth =1;
function setup() {
createCanvas(400, 400);
noFill();
stroke(0);
//drawArc(width / 2, height / 2, 200, radians(-90), radians(270), 7, 0.6);
//noLoop();
frameRate(1);
}
function drawArc(x, y, radius, startAngle, endAngle, depth, reductionFactor) {
ellipse(x + radius * sin(startAngle), y + radius * cos(startAngle), 5, 5);
//ellipse(x + radius * sin(endAngle), y + radius * cos(endAngle), 5, 5);
arc(x, y, radius * 2, radius * 2, startAngle, endAngle);
if (depth === 0) {
//arc(x, y, radius * 2, radius * 2, startAngle, endAngle);
} else {
let midAngle = (startAngle + endAngle) / 2;
let newRadius = radius * reductionFactor;
drawArc(x, y, newRadius, startAngle, midAngle, depth - 1, reductionFactor);
drawArc(x, y, newRadius, midAngle, endAngle, depth - 1, reductionFactor);
}
}
function draw() {
background(220);
drawArc(width / 2, height / 2, 200, radians(-90), radians(270), depth, 0.9);
depth ++;
print(depth);
}