Recursive Circles turning

WoooooooooooooooooooooooW

Log in to post a comment.

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

var offSetX = 0;
var offsetY = 0
var cycles = 0;
var offsetRadians = 0;

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