SpiralSquare Slow

SpiralSquare Slow (delay)

Created by davidgiorgi on 2018/12/14
793
0

Log in to post a comment.

// Global code will be evaluated once.
const turtle = new Turtle();
const rect = { 
    w:200, h:200,    
    get tl(){ return {x:this.w/-2,y:this.h/-2}; }
};

// Helpers
function D2R(a){ return a / 180 * Math.PI; }

turtle.penup();
turtle.goto(rect.tl.x, rect.tl.y);
turtle.pendown();

var length = rect.w;
var angle = 0.5;
var sinAngle = Math.sin(D2R(angle));

// The walk function will be called until it returns false.
function walk(i) 
{
    turtle.forward(length);
    turtle.right(90+angle);
    
    length -= sinAngle * length;
    
    
    

demo();
    
    return length > 0.5 && i < 1000;
}


function demo() {
 for(var i=0;i<1000;i++){
     console.log(1);
 }

}