The mold

Different oscillations thrown together without any sort of idea

Log in to post a comment.

// Global code will be evaluated once.
Canvas.setpenopacity(.3);

const turtle = new Turtle();
turtle.rect = 
{ 
    w:200, h:200,    
    get tl(){ return {x:this.w/-2,y:this.h/-2}; },
    get l(){ return {x:this.w/-2,y:0}; }
};
turtle.wrap = function()
{
    // move all to Q1
    w = this.rect.h, h = this.rect.h;
    x = this.x() + w/2, y = this.y() + h/2;

    // no need to wrap?
    if (x >= 0 && x <= w && y >= 0 && y <= h) return;
    
    // wrap
    while (x < 0) x += w;
    x = x % w;
    while (y < 0) y += h;
    y = y % h;
    
    // move back to center and don't draw wrapped lines
    this.penup();
    this.setx( x-w/2 );
    this.sety( y-h/2 );
    this.pendown();
}
// Helpers
function D2R(a){ return a / 180 * Math.PI; }
//turtle.penup();
//turtle.goto(rect.l.x, rect.l.y);
//turtle.pendown();
seed = Math.random()*1800;
// The walk function will be called until it returns false.
function walk(i) 
{
    bend = 3 - i / seed;
    dir = 10 + i / 14;
    
    d1 = dir + Math.sin(D2R(i*bend));
    d2 = bend + Math.cos(D2R(i/306));
    
    turtle.forward(1);
    turtle.seth( turtle.h() + d1 * d2);
    
    turtle.wrap();
    
    return i < 100000;
}