Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Thursday, 17 September 2009

When Terminals Don't Matter (A Simpler Koch flake)

   1 //simpler hexaflake.pde
   2 float X1 = 0.5;
   3 float X2 = 0.25;
   4 float Y1 = sqrt(3)/4;
   5 float Y2 = 0;
   6 float REDUCE = 0.3333;
   7 void setup(){
   8   size(1000, 1000);
   9   smooth(); 
  10   background(0);
  11   fill(255);
  12   noStroke();
  13   drawHexaflake(width/2, height/2, height/1.5);
  14 }
  15 
  16 void drawHexaflake(float cx, float cy, float sz){
  17   if (sz < 1){
  18     ellipse(cx, cy, sz, sz);
  19     noLoop();   
  20   }
  21   else{     
  22     float x0 = cx - (X1 * sz);
  23     float y0 = cy;
  24     float x1 = cx - (X2 * sz);
  25     float y1 = cy  - (Y1 *sz);
  26     float x2 = cx + (X2 * sz);
  27     float y2 = cy  - (Y1 *sz);
  28     float x3 =  cx + (X1 * sz); 
  29     float y3 = cy;
  30     float x4 = cx + (X2 * sz);
  31     float y4 = cy + (Y1 * sz);
  32     float x5 = cx - (X2 * sz);
  33     float y5 = cy + (Y1 * sz);
  34     drawHexaflake(x0, y0, sz*REDUCE);
  35     drawHexaflake(x1, y1, sz*REDUCE);
  36     drawHexaflake(x2, y2, sz*REDUCE);
  37     drawHexaflake(x3, y3, sz*REDUCE);
  38     drawHexaflake(x4, y4, sz*REDUCE);
  39     drawHexaflake(x5, y5, sz*REDUCE);
  40   }
  41 }

Terminals don't really matter at this resolution.

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2