Tinkerings with math...
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(0.5);
// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();
const pi = Math.PI;
let rx = 95.0;
let ry = 50.0;
let ang = 0.0;
let step = pi / 180.0;
let freq = 3.0;
let freqMod = 199.0;
// The walk function will be called until it returns false.
function walk(i)
{
turtle.penup();
turtle.goto( rx*Math.sin(ang), ry*Math.cos(ang*freq) + Math.cos(ang*freqMod) );
ang += step;
turtle.pendown();
turtle.goto( rx*Math.sin(ang), ry*Math.cos(ang*freq) + Math.cos(ang*freqMod) );
return ang < pi*20.0;
}