ex2-warmup2
ex2-warmup2
Log in to post a comment.
// 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 r0 = 100;//min=5,max=100,step=1
const rI = 50;//min=5,max=100,step=1
const nSteps = 1000;//min=10,max=10000,step=1
const a = 1;//min=1,max=10,step=0.1
const nCircles = 20;//min=5,max=1000,step=1
Canvas.setpenopacity(1);
// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();
let rA=r0+rI;
for(let i=0;i<nSteps;i++){
let t=nCircles*(2*Math.PI/nSteps)*i;
let x= rA*Math.cos(t)-a*Math.cos(rA/rI*t);
let y= rA*Math.sin(t)-a*Math.sin(rA/rI*t);
turtle.goto(x,y);
if(i==0){
turtle.pendown();
}
}