Plot a Sine Wave
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
const xStepSize = 0.1; // min = 0.1 max = 10 step=0.1
// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();
turtle.goto(-90,0);
var x = -90;
var y = 0;
// The walk function will be called until it returns false.
function walk(i)
{
x = x + xStepSize;
y = Math.cos(x /10) * 25 ;
turtle.setx(x)
turtle.sety(y);
turtle.pendown();
return i < 180 / xStepSize;
}