Snow

Cause it's xmas

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

const width = 3;
const length = 40;
const max_depth = 3;
const grid = 10;

// Global code will be evaluated once.
const turtle = new Turtle();

turtle.penup();
turtle.pendown();

function flake(len, wid, num, depth) {
    for (let i=0;i<num;i++) {
        turtle.forward(len);
        if (depth >= max_depth) {
            turtle.left(90);
            turtle.forward(wid);
            turtle.left(90);
        } else {
            turtle.right(120);
            flake(len/4, wid, 5, depth+1);
        }
            
        turtle.forward(len);
        turtle.right(120);
    }
}

// The walk function will be called until it returns false.
function walk(i) {
    let xc = i % grid;
    let yc =  Math.floor(i/grid);
    turtle.penup()
    turtle.goto(grid+2*grid*xc-100, grid+2*grid*yc-100)
    turtle.right(Math.random()*360)
    yc=yc+5
    turtle.forward(yc*Math.random()*grid/5)
    turtle.pendown()
    flake(length*(1+(yc*Math.random())/5)/(2*grid),width*(1+(yc*Math.random())/5)/(2*grid),6,1)
    return i<99
}