up down up down
I generate several different copies then plot each one using a different color pen to create colorful drawings with the wiggles crisscrossing across the page
Log in to post a comment.
// so pretty Oh so pretty Glitchy const rnd = (max) => Math.random() * max; const rand = (min, max) => Math.random() * (max - min) + min; const random = Math.random; const abs = Math.abs; const atan2 = Math.atan2; const PI = Math.PI; //avoid edges by so many units const baseAngle = 10; // min=0, max=180, step=0.1 const baseStep = 5; // min=0, max=180, step=0.1 const jiggleAngle = 3; // min=0, max=30, step=0.1 const jiggleStep = 3; // min=0, max=30, step=0.1 const length = 5000; // min=100, max=50000, step=100 const margin = 10; // min=0, max=100, step=1 Canvas.setpenopacity(1); // Global code will be evaluated once. const turtle = new Turtle(); // Orient turtle towards origin, used to turn around on the margins const turnToHome = () => { turtle.setheading(180+atan2(turtle.y(),turtle.x())*180/PI); } turtle.left((180-baseAngle)/2); // The walk function will be called until it returns false. function walk(i) { turtle.right(180-baseAngle+rand(-jiggleAngle,jiggleAngle)); turtle.forward(baseStep+rnd(jiggleStep)); turtle.left(180-baseAngle+rand(-jiggleAngle,jiggleAngle)); turtle.forward(baseStep+rnd(jiggleStep)); if (abs(turtle.x())>100-margin || abs(turtle.y())>100-margin) { turnToHome(); turtle.left((180-baseAngle)/2); if (i>length) return false; } return true; }