// Welcome to Turtletoy!
//
// Turtletoy is a community for creative coding. We believe the joy 
// is in the craft. 
//
// ---------------------------------------------------------------
// A NOTE ON AI:
// Please do not publish code entirely generated by AI. 
// We want to see YOUR creativity, your mistakes, and your logic. 
// If you use AI to learn, try to rewrite the code yourself before 
// sharing, so others can learn from your human approach.
// ---------------------------------------------------------------
//
// API Reference: https://turtletoy.net/syntax


const n = 500 //min = 100, max = 10000, step = 1
const stepsize = 1 //min = 1, max = 10, step = 1
const expo1 = 7 // min = -10, max = 10 step = 1
const expo2 = 2 // min = -10, max = 10 step = 1
const expo3 = 1 // min = -10, max = 10 step = 1
const expo4 = 2 // min = -10, max = 10 step = 1

const add1 = 3 // min = 1, max = 25 step = 1
const add2 = 1 // min = 1, max = 25 step = 1
const add3 = 5 // min = 1, max = 25 step = 1
const add4 = 3 // min = 1, max = 25 step = 1

const vf1 = 2 // min = 1, max = 25, step = .1
const vf2 = 6 // min = 1, max = 25, step = .1
const vf3 = 6 // min = 1, max = 25, step = .1
const vf4 = 2 // min = 1, max = 25, step = .1

const vvf1 = 1.5 // min = -5, max = 5, step = .01
const vvf2 = 0.25 // min = -5, max = 5, step = .01
const vvf3 = 0.2 // min = -5, max = 5, step = .01
const vvf4 = -0.66 // min = -5, max = 5, step = .01

Canvas.setpenopacity(1);

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

for(let i = 1; i<n; i= i + stepsize){
    gostart(i);
    turtle.pendown()
    goend(i);
    turtle.penup();
}

function gostart(k){
    let x1 = 60*vvf1*(Math.sin((vf1*Math.PI*k/n)+(Math.PI/add1))**expo1)
    let y1 = -60*vvf2*(Math.cos((vf2*Math.PI *k/n) + (Math.PI /add2)) **expo2)
    turtle.goto(x1, y1)
}

function goend(k){
    let x2 = 60* vvf3*(Math.sin((vf3* Math.PI*k/n)+(Math.PI/add3))**expo3)
    let y2 = -60 *vvf4*(Math.sin((vf4*Math.PI*k/n)-(Math.PI/add4))**expo4)
    turtle.goto(x2,y2)
}