playing with turn and velocity parameters. every parameter reflects and updates itself.
this is a port my python turtle code from here: github.com/heerdyes/…es/metapattern_01.py
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax Canvas.setpenopacity(0.80); // Global code will be evaluated once. const scv=1; // min=-10, max=10, step=0.1 const smn=-2; // min=-10, max=10, step=0.1 const smx=4; // min=-10, max=10, step=0.1 const sdt=0.25; // min=-10, max=10, step=0.01 const tcv=-1; // min=-90, max=90, step=1 const tmn=-39; // min=-90, max=90, step=1 const tmx=3; // min=-90, max=90, step=1 const tdt=1; // min=-10, max=10, step=0.5 const turtle = new Turtle(); turtle.up(); turtle.goto(-50,10); turtle.down(); function reflect(param){ if(param.currval<param.min){ param.delta=-param.delta; param.currval=param.min; }else if(param.currval>param.max){ param.delta=-param.delta; param.currval=param.max; } } function update(param){ param.currval+=param.delta; reflect(param); } // functions function navgen(steplenparam,turnparam){ for(var i=0;i<360;i++){ update(steplenparam); console.log(steplenparam); turtle.forward(steplenparam.currval); update(turnparam); console.log(steplenparam); turtle.right(turnparam.currval); } } // The walk function will be called until it returns false. function walk(i) { navgen({currval:scv,min:smn,max:smx,delta:sdt},{currval:tcv,min:tmn,max:tmx,delta:tdt}); return i < 48; }