circle roots
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax Canvas.setpenopacity(1); // Global code will be evaluated once. const turtle = new Turtle(); const iterations=140; // min=2, max=150, step=1 turtle.penup(); turtle.goto(-50,-20); turtle.pendown(); function randomNumber(min, max) { return Math.random() * (max - min) + min; } var roots = [[20,400],[36,300],[53,500],[82,400],[137,400],[234,300],[295,500],[332,400]]; function centered_circle(radius,start,arclength) { turtle.jump(0,0); turtle.setheading(0); turtle.penup(); turtle.forward(radius); turtle.setheading(90); turtle.circle(radius,start-arclength/(2*radius)); turtle.pendown(); turtle.circle(radius,arclength/radius); } // The walk function will be called until it returns false. function walk(i) { let j=0; while (j < roots.length) { centered_circle(i,roots[j][0],roots[j][1]); if(roots[j][1]>randomNumber(70,600)) { roots[j]=[roots[j][0]-30,50]; roots.splice(j+1,0,[roots[j][0]+30,50]); } else { roots[j]=[roots[j][0]*randomNumber(.98,1.02),roots[j][1]*randomNumber(.5,1.8)]; } j++; } return i < iterations; }