Labels

Friday 17 August 2012

Coding the base snowflake

Here I created the snowflake that I would use as the base for my structure and then moving into the noise. I felt that this flake looked spindly enough to create a complex design that wasn't too busy. For the code, I used basic lines and variables to create the structure so that it can be easily adapted if I wish to change it throughout the design.



void snowflake()
{
  float x = xp;
  float y = yp;

  float h  = 50*s;
  float h2 = 35*s;
  float h3 = 10*s;
  float h4 = 8*s;
  float h5 = 5*s;
  float h6 = 8*s;

  //vertical large
  line(x + h/2, y, x + h/2, y + h);
  line(x + (h/2-h5), y - h5, x + h/2, y);
  line(x + (h/2+h5), y - h5, x + h/2, y);
  line(x + (h/2-h5), y +(h+h5), x + h/2, y + h);
  line(x + (h/2+h5), y +(h+h5), x + h/2, y + h);
  //horizonal large
  line(x, y + h/2, x + h, y + h/2);
  line(x - h5, y +(h/2-h5), x, y + h/2);
  line(x - h5, y +(h/2+h5), x, y + h/2);
  line(x +(h+h5), y +(h/2-h5), x + h, y + h/2);
  line(x +(h+h5), y +(h/2+h5), x + h, y + h/2);
  //top left to bottom right
  line(x + h3, y + h3, x + (h-h3), y + (h-h3));
  line(x +(h-2*h4), y + h4, x + (h-2*h4), y +2*h4);
  line(x +(h-h4), y + (2*h4), x + (h-2*h4), y +2*h4);
  line(x + h4, y +(h-2*h4), x +2*h4, y +(h-2*h4));
  line(x + 2*h4, y +(h-h4), x +2*h4, y +(h-2*h4));
  //top right to bottom left
  line(x + h3, y + (h-h3), x + (h-h3), y + h3);
  line(x + h4, y + 2*h4, x + 2*h4, y + 2*h4);
  line(x + 2*h4, y + h4, x + 2*h4, y + 2*h4);
  line(x +(h-2*h4), y + (h-h4), x +(h-2*h4), y +(h-2*h4));
  line(x +(h-h4), y +(h-2*h4), x +(h-2*h4), y +(h-2*h4));
}

No comments:

Post a Comment