xxxxxxxxxx
83
let D = 0;
let mind = 10;
function setup() {
let c = createCanvas(2048, 2048);
background(15);
// stroke(255);
noFill();
translate(width/2, height/2);
D = width/4;
stroke("yellow");
strokeWeight(2);
circle(0, 0, D);
draw_circles4(0, 0, D, -1);
saveCanvas(c, 'Recursion2K', 'png');
}
function draw_circles(r){
circle(0,0, r);
if(r>10){
draw_circles(r-10);
}
}
function draw_circles2(x, y, r){
circle(x-r/2,0, r);
circle(x+r/2,0, r);
if(r>10){
draw_circles2(x-r/2,0,r/2);
draw_circles2(x+r/2,0,r/2);
}
}
function draw_circles3(x, y, r){
if(r>10){
// circle(x,0, r);
let mul = 2;
circle(x-r/2,0, r/mul);
circle(x+r/2,0, r/mul);
draw_circles3(x-r/2,0,r/mul);
draw_circles3(x+r/2,0,r/mul);
}
}
function draw_circles4(x, y, r, dir){
if(r>mind){
let offset = 3*r/4;
let colorr = (r-mind)/(D-mind)*255+2;
stroke(colorr, 0, 0);
if(dir != 0){
stroke(colorr, colorr, 0);
circle(x-offset,y, r/2);
draw_circles4(x-offset,y,r/2,2);
}
if(dir != 2){
stroke(colorr/2, colorr, 0);
circle(x+offset,y, r/2);
draw_circles4(x+offset,y,r/2,0);
}
if(dir != 3){
stroke(colorr, colorr/2, 0);
circle(x,y-offset, r/2);
draw_circles4(x,y-offset,r/2,1);
}
if(dir != 1){
stroke(colorr, colorr, 0);
circle(x,y+offset, r/2);
draw_circles4(x,y+offset,r/2,3);
}
}
}
function draw() {
}