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

Sunday, 8 November 2009

Towards a Pentigree (accidental art)

   1 class Element{
   2   float x, y, theta;
   3   Element(float x0, float y0, float angle){
   4     x =x0;
   5     y = y0;
   6     theta = angle;
   7   }
   8 
   9   void turnLeft(float angle){
  10     theta += angle;
  11   }
  12 
  13   void goForward(float step){
  14     float x1 = x;
  15     float y1 = y;
  16     x += step * cos(theta);
  17     y += step * sin(theta);
  18     line(x1, y1, x, y);
  19   }
  20 }
  21 Element turtle;
  22 
  23 int ITERATIONS = 7; 
  24 float elementSize = 3;
  25 
  26 void pentigree(int n) {
  27   if (n == 0) turtle.goForward(elementSize);
  28   else {
  29     turtle.turnLeft(PI/10);
  30     pentigree(n-1);
  31     turtle.turnLeft(PI*4/5);
  32     pentigree(n-1);
  33     turtle.turnLeft(-PI/5);
  34     pentigree(n-1);
  35     turtle.turnLeft(-PI/10);
  36     pentigree(n-1);
  37     turtle.turnLeft(PI/10);
  38     pentigree(n-1);
  39   }
  40 }
  41 
  42 void setup(){
  43   size(1000, 800);
  44   smooth();
  45   background(0);
  46   stroke(255, 0, 0);
  47   turtle = new Element(width/4, height/2, 0);  
  48   pentigree(ITERATIONS);
  49 }
 

  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here I've gone for the turtle approach to implementing a Pentigree. I have recently had much success using Lindenmayer Systems implemented in ruby processing.  I will not be pursue that any further using java processing, because I stumbled upon implementations included with the ide (Under "Topics" Fractals and L-Systems).

1 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