# Laser-cut algorithmic snowflakes

Follow these instructions to create vector diagrams of snowflakes and use a laser cutter to cut them from acrylic, wood, or paper.  The snowflakes are generated using a randomized algorithm, so no two will be alike.

Before you begin, make sure you have Processing and Inkscape installed on your computer.  Processing is available at www.processing.org, and Inkscape is available at www.inkscape.org.
Remove these ads by Signing Up

## Step 1: Create the program

Paste the following code into a blank Processing sketch, and save it as "algorithmic_snowflakes.pde":

int SIZE = 100;
int DEPTH = 3;
int THICKNESS = 12;
float[] fractions = new float[DEPTH];
int[] angles = new int[DEPTH];
int saves = 0;

void setup() {
size(500,500);
stroke(0,0,0);
pushMatrix();
strokeWeight(THICKNESS);
fill(255,255,255);
snowflake();
}

void mouseClicked() {
if (mouseButton == LEFT) {
save("snowflake" + saves + ".png");
saves = saves + 1;
}
snowflake();
}

void snowflake() {
background(255,255,255);
translate(250,250);
for(int i = 0; i<DEPTH; i++) {
fractions[i] = 0.5 + 0.25*(random(1) - random(1));
angles[i] = int(60 + random(40) - random(40));
}
for(int i = 0; i<6; i++) {
branch(SIZE,0);
}
ellipse(0,0,0.25*SIZE,0.25*SIZE);
ellipse(SIZE,0,0.25*SIZE,0.25*SIZE);
}

void branch(int size, int depth) {
if(depth<DEPTH) {
line(0,0,size,0);
branch(int(fractions[depth]*size),depth+1);
pushMatrix();
translate(fractions[depth]*size,0);
branch(int(fractions[depth]*size),depth+1);
pushMatrix();
branch(int(fractions[depth]*size),depth+1);
popMatrix();
pushMatrix();
branch(int(fractions[depth]*size),depth+1);
popMatrix();
popMatrix();
}
}

void draw() {
}

## Step 2: Generate snowflakes

Run the sketch.  A window will pop up displaying a randomized snowflake.  Clicking on the image will save that image to the sketch folder and generate a new snowflake.  Click as many times as you want to continue generating more snowflakes.

Note the parameters SIZE, DEPTH, and THICKNESS, in case you want to change these.  SIZE affects how big the snowflake is.  DEPTH determines how many times the fractal-like algorithm iterates, which affects how intricate the snowflakes are.  THICKNESS affects the thickness of the branches.

## Step 3: Embed the images in Inkscape

Open a new document in Inkscape.  Drag the snowflake *.png files from the sketch folder onto the Inkscape document.  Inkscape will give you the choice of either embedding or linking to the images.  Choose "embed."