Instructables

Laser-cut algorithmic snowflakes

Picture of 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 adsRemove 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);
  rotate(radians(-90));
  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);
      rotate(radians(60));
  }
  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();
    rotate(radians(-angles[depth]));
    branch(int(fractions[depth]*size),depth+1);
    popMatrix();
    pushMatrix();
    rotate(radians(angles[depth]));
    branch(int(fractions[depth]*size),depth+1);
    popMatrix();
    popMatrix();
  } 
}

void draw() {
}

Step 2: Generate snowflakes

Picture of 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

Picture of Embed the images in Inkscape
inkscape1.png
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."
d_f made it!4 months ago

I made these! They came out perfectly.

It took me 90 minutes of burn time at 90% power on a 40w laser to make 60 roughly 2-inch-wide snowflakes, using 3 sheets of 18x24x0.11 inch acrylic (very cheap stuff from a hardware store). They look much better in person than they do in pictures.

1966759_704861469995_393436580_n.jpg
perplexity (author)  d_f4 months ago
Excellent! I'm glad they turned out so well; I tried to do it with a thicker acrylic sheet and it warped a bit in the cutter - some of the snowflakes cracked while I was punching them out.
rachel7 months ago
What a great idea! May try this for small gifts next year :)