### Snowflake 005

A Single Snowflake working towards snowflakes Dan Catt see his work at: revdancatt.com/penplotter/036-snowflakes Dan's list of Pen Plotter Tools at: revdancatt.com/penplotter/

```// Forked from "Stars 001" by rupertxrussell
// https://turtletoy.net/turtle/01d0bf10d6

// You can find the Turtle API reference here: https://turtletoy.net/syntax
// MIT Licence

// Draw a Single Snowflake
// working towards  Dan Catt's snowflakes
// see his work at: https://revdancatt.com/penplotter/036-Snowflakes
// See Dan's full list of Pen Plotter Tools at: https://revdancatt.com/penplotter/

Canvas.setpenopacity(1);

let maxScale=95;
const turtle = new Turtle();

// generate a random number of branches
let nBranches = 3; //min=2 max=15 step=1
snowFlake(0, 0);

function snowFlake(randomX, randomY) {
// scale =  getRandomInt(maxScale + 1);
scale = maxScale;
armLength = scale;
turtle.penup();
turtle.goto(randomX, randomY);

// N S  arm
turtle.penup();
turtle.goto(randomX, randomY);
turtle.pendown();
turtle.penup();
turtle.forward(scale);
let position3 = turtle.position();
turtle.pendown();
turtle.right(180);
turtle.forward(scale * 2);
let position0 = turtle.position();

// NW SE arm
turtle.penup();
turtle.goto(randomX, randomY);
turtle.pendown();
turtle.penup();
turtle.forward(scale);
turtle.pendown();
let position2 = turtle.position();
turtle.right(180);
turtle.forward(scale * 2);
let position5 = turtle.position();

// SW NE arm
turtle.penup();
turtle.goto(randomX, randomY);
turtle.penup();
turtle.forward(scale);
turtle.pendown();
let position1 = turtle.position();
turtle.right(180);
turtle.forward(scale * 2);
let position4 = turtle.position();

/*
// draw star of david
turtle.jump(position0);
turtle.pendown();
turtle.goto(position2)
turtle.goto(position4)
turtle.goto(position0)

turtle.jump(position5);
turtle.pendown();
turtle.goto(position1)
turtle.goto(position3)
turtle.goto(position5)
*/

// draw nBarnches
let stepLength = armLength / nBranches;

for(let arm = 0; arm < 6; arm ++){

for(let n = 0; n < nBranches; n ++){
let branchLength = (armLength - stepLength * n) / 2
// go to center of the snowflake
turtle.penup();
turtle.goto(randomX, randomY);
turtle.right(180);
turtle.forward(stepLength * n);
turtle.right(60);
turtle.pendown();
turtle.forward(branchLength);
turtle.back(branchLength);
turtle.left(60 * 2)
turtle.forward(branchLength);
}
}
}

// Used to draw the angled branches
function branch(armLength, stepLength){
let branchLength = (armLength - stepLength) / 2
return branchLength;
}

function getRandomInt(max) {
return Math.floor(Math.random() * max);
}```