Recursive circles

WooooooooooooW

Created by Glenn on 2018/10/22
129
0

Log in to post a comment.

// Global code will be evaluated once.
const turtle = new Turtle();
var depthMax = 4;

function circle(posX, posY, radius)
{
    turtle.up();
    turtle.goto(posX, posY - radius);
    turtle.down();
    turtle.circle(radius, 360)
    
}
function circleGroup(posX, posY, depth)
{
    if(depth > depthMax)
        return;
        
    var bla = depth + 1;
    
    var length = 8
    for(var j = 0; j < length; j++)
    {
        var radius = 50 / depth;
        var percentage = j / (length - 1);
        var x = posX + Math.cos(percentage * Math.PI * 2) * radius;
        var y = posY + Math.sin(percentage * Math.PI * 2) * radius;
        circle(x, y, radius * 0.4); 
        circleGroup(x, y, bla);
    }
}
// The walk function will be called until it returns false.
function walk(i) {
    
    circleGroup(0, 0, 1);
    
 
    return i < 1;
}