Snowflake 001

Draws a simple single Snowflake

Log in to post a comment.

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

const arms = 10; //min=4 max=36 step=1
const armLength = 55; //min=10 max=80 step=1
const numTwigs = 8; //min=3 max=8 step=1
const twigLength = 14; //min=3 max=25 step=1

// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();
turtle.goto(-50,-50);
turtle.pendown();

// The walk function will be called until it returns false.

    for (let i = 0; i < arms ; i++) {
    turtle.penup();
    turtle.goto(-0,-0);
    turtle.pendown();
    
    turtle.right(360/arms);
    
    for(let n = 0; n < numTwigs; n ++){
        turtle.forward(armLength / numTwigs);
        turtle.right(360/arms);
        turtle.forward(twigLength);
        turtle.back(twigLength);
        turtle.left(360/arms * 2);
        turtle.forward(twigLength);
        turtle.back(twigLength);
        turtle.right(360/arms);
    }
    turtle.forward(twigLength * 1.5);
    turtle.back(armLength);
        
}