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, 22 November 2009

Lindenmayer systems to draw fractals

 For those of you like me interested in fractal art there is one reference I can really recommend and what is more you probably won't have to pay a penny for it.

Przemyslaw Prusinkiewicz
Aristid Lindenmayer
The Algorithmic Beauty of Plants
With
James S. Hanan
F. David Fracchia
Deborah Fowler
Martin J. M. de Boer
Lynn Mercer


Another book that you can probably afford to buy if it isn't in your library is

Fractals "Images of Chaos" by Hans Lauwerier, particularly interesting for those of you wanting to have a go at some "basic" programming, there are recipes for various fractals included.

There is also some pretty good stuff over at wikipedia:-
http://en.wikipedia.org/wiki/L-system

For my latest experiments with L-Systems and fractals all in ruby-processing (some using ruby-processing context-free DSL) checkout my ruby-processing blog

Tuesday, 10 November 2009

Fractal Art animation implemented in processing.js

Here is the embedded animation from hascanvas.com



You need canvas support for you browse so OK on chrome, safari and firefox. Internet explorer you must be joking!!!

Refresh the browser to re-run the animation. (Click on it to see it full size or got to hascanvas)

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

Thursday, 5 November 2009

Lévy curve implemented in processing

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

 

Tuesday, 3 November 2009

Lévy curve

Lévy curve
levy.cfdg
   1 startshape levy
   2 background{b -1}
   3 rule levy{
   4 line{}
   5 levy{r 45 s (1/sqrt(2)) x -1}
   6 levy{r -45 s (1/sqrt(2)) x -1}
   7 }
   8 rule line{
   9 SQUARE{s 1 .1 b 1 h 360 b 1 sat 1}
  10 }
 

 
















levy.cfdg

Alternative Lévy Curve
   1 startshape levy
   2 background{h 0 sat .01 b .01}
   3 
   4 rule levy {
   5 SQUARE{s 1 .5 a -.8  b .7 sat .3}
   6 levy{s (1/sqrt(2)) r -45 x .25}
   7 levy{s (1/sqrt(2)) r 45 x -.25}
   8 }
   9  

 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
levy.cfdg
Yet another Lévy Curve
   1 startshape levy
   2 background{b 1}
   3 
   4 rule levy {
   5 segment{}
   6 levy{s (1/sqrt(2)) r -45 x .25}
   7 levy{s (1/sqrt(2)) r 45 x -.25}
   8 }
   9 
  10 path segment{
  11 MOVETO{x -.5 y -.5}
  12 LINETO{x -.5}
  13 LINETO{x .5}
  14 LINETO{x .5 y -.5}
  15 STROKE{width .05 b -.5 a -.7}
  16 }
 

 

Monday, 2 November 2009

Colorful wig (or Pythagoras tree variant)

wig.cfdg

   1 startshape wig
   2 background{b -1}
   3 rule wig
   4 {
   5 oblong{b .8 sat .8}
   6 2* {y .5 x -.25 r -90 |h 220}
   7  wig{r 30  y 1 x -.25 s .707 h 6|}
   8 }
   9 
  10 path oblong{
  11 MOVETO{x -.25 y -.5}
  12 LINETO{x .25 y -.5}
  13 LINETO{x .25 y .5}
  14 LINETO{x -.25 y .5}
  15 CLOSEPOLY{}
  16 FILL{|h 0 b .1 sat .1}
  17 }
 
An alternative title might have been colourful brain/brain stem?
 
To get a regular Pythagoras tree substitute a SQUARE primitive (or a square path ie .5 for .25) for the oblong, and change -.25 to -.5 lines 6, and 45 for 30 line 7.



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