Fork: Adolecência com o GraFORTH

Now with a slider to adjust the steps (by default it plots like a solid block if you don't lower the step count)

Log in to post a comment.

// Forked from "Adolecência com o GraFORTH" by nfw
// https://turtletoy.net/turtle/9a1ba733bb

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1); // Changed to 1.0 for plotting (solid lines)

// Global code will be evaluated once.
const turtle = new Turtle();
turtle.radians();
turtle.penup();

const radius = 80.0;

const steps = 300; // min=300, max=8192, step=1

const xp = Math.floor(steps / 3);
const yp = Math.floor(steps / 3) + 1;

function walk(i) {
    x = radius * Math.sin((i * xp * 2.0 * Math.PI) / steps);
    y = radius * Math.sin((i * yp * 2.0 * Math.PI) / steps);
    
    turtle.goto(x, y);
    
    if (0 == i) {
        turtle.pendown();
    }
    
    return i < steps;
}