Sine Waves
Log in to post a comment.
// I am trying to replicate an oscilloscope // So far I am having limited success but it does create some interesting curves // Released under the MIT licence // https://mit-license.org/ // you can use this for commercial gain if you like eg you can sell artworks with this image. // 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 frequency = 21.4; //min=1 max=100 step=0.1 const Yscale = 50; //min=0 max=100 step=1 const steps = 302; //min=10 max=3250 step=1 const stepsize = 0.59; //min=0.006 max=1 step=0.01 const offsetX = 5.80; //min=-20 max=20 step=0.1 var x = -100; x=x + offsetX; turtle.penup(); // The walk function will be called until it returns false. function walk(i) { if(i > 0){ turtle.pendown(); } x += stepsize; y = Math.sin(x * frequency) * Yscale; turtle.goto(x ,y) return i < steps; }