Fork: Lissajous Curve

// From Python Turtle - Lissajous Curve - www.101computing.net/python-turtle-lissajous-curve/

Log in to post a comment.

// Forked from "Lissajous Curve" by rupertxrussell
// https://turtletoy.net/turtle/a39b32449b
// https://turtletoy.net/turtle/853747d53f#scale=95,a=5.2,aFine=0.099,b=1,bFine=0.001,delta=1.215,stepsCourse=392,stepsFine=0,stepsSuperFine=0.723
// From Python Turtle - Lissajous Curve - www.101computing.net/python-turtle-lissajous-curve/
// 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 scale = 95;  //min=10 max=100 step=1

const A = scale;
const B = scale;
const a = 5.2; //min=1 max=100 step=0.1
const aFine = 0.099; //min=0.001 max=1 step=0.001

const b = 1; //min=1 max=100 step=0.1
const bFine = 0.001; //min=0.001 max=1 step=0.001
const delta = 1.215; //min=0.001 max=3.14 step=0.001
const stepsCourse = 392; //min=10 max=4800 step=1
const stepsFine = 0; //min=0 max=100 step=1 
const stepsSuperFine = 0.723; //min=0 max=1 step=0.001
var t=0;

turtle.penup();

// The walk function will be called until it returns false.
function walk(i) {
    
    if(i >0){
    turtle.pendown();
    }

    t+=stepsCourse + stepsFine + stepsSuperFine;

    // Apply Lissajous Parametric Equations
    x = A * Math.sin(a + aFine *t + delta);
    y = B * Math.sin(b + bFine *t);

    turtle.goto(x,y)
    return i < stepsCourse + stepsFine + stepsSuperFine;
}