Til(t)ed squares

Simple nested, tilted squares.

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

let size = 180;

// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();
turtle.goto(-95, -95);

// The walk function will be called until it returns false.
function walk(i) {
    // Draw a square
    turtle.pendown();
    for (let j = 0; j < 4; j++) {
        turtle.forward(size);
        turtle.right(90);    
    }
    
    // Rotate and walk inwards
    turtle.penup();
    turtle.right(45);
    turtle.forward(22);
    turtle.left(41);
    size -= 30;
    
    return size > 0;
}