loading
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.

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() {
}
 
d_f made it!1 year 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_f1 year 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.
rachel1 year ago
What a great idea! May try this for small gifts next year :)