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

Saturday, 5 September 2009

Towards a pentaflake cfdg

From a simple set of cfdg rules, you can easily create a pentagon from the terminal shape TRIANGLE. Here I have created an approximate unit pentagon, I have reduced the triangle size, rotated it, displaced it on the y-axis, and rotated it 5 times by 72 degrees (0.4π if you work in radians) to get the pentagon.

   1 startshape pentagon
   2 background {b 0.8 h 60 sat 0.5}
   3 rule pentagon{
   4     5 * { r 72 }
   5     TRIANGLE {h 220 sat 0.8 b .8 r 180 s .57 y .23 a -.5 }
   6 }

To make the triangle easily visible I have set the alpha value to -0.5, it seems to be a convention in context free rules to omit leading 0, I've messed up here. Here is the approximate pentagon.



Just messing and moving toward a pentaflake gave this set of rules:-

   1 startshape pentaflake
   2 background {b 0.8 h 60 sat 0.8}
   3 
   4 rule pentaflake{
   5     5 * { r 72 }
   6     pentagon {sat 0.5 b .5 r 180 s .447 y .23 a -.5}    
   7     }
   8 
   9 rule pentagon{
  10     5 * { r 72 }
  11     TRIANGLE {h 220 sat 0.08 b .08 r 180 s .57 y .23}
  12 }

And here is the result:-


Getting closer without recursion (yet):-

   1 startshape pentaflake
   2 background {b 0.8 h 60 sat 0.8}
   3 
   4 rule pentaflake{
   5     5 * { r 72 }
   6     pentabase {sat 0.5 b .5 s .447 y .41}    
   7     }
   8 
   9 rule pentabase{
  10     5 * { r 72 }
  11     pentagon {sat 0.5 b .5 r 180 s .447 y .35}    
  12     }
  13 
  14 rule pentagon{
  15     5 * { r 72 }
  16     TRIANGLE {h 220 sat 0.08 b .08 r 180 s .57 y .23}
  17 }

Looking more like it:-


Add a bit of recursion and serendipity is best:-

   1 startshape pentaflake
   2 background {b -1}
   3 
   4 rule pentaflake{
   5     pentagon {} 
   6     5 * { r 72 } pentaflake { b .8 s .447 y .41 r 72 a -.5}  
   7     }
   8 
   9 rule pentagon{
  10     5 * { r 72 }
  11     TRIANGLE {r 180 s .57 y .23 }
  12 }

WoW well thats what I thought:-


Finally using a simpler pentagon we get something like a snowflake, well at least a fractal like recursive structure.

   1:startshape pentaflake
   2:background {b -1}
   3:
   4:rule pentaflake{
   5:    pentagon {b .01} 
   6:    5 * { r 72 } pentaflake { b .9 s .38 y .65 r 72 }  
   7:    }
   8:
   9:path pentagon{
  10:MOVETO{x 0 y 1}
  11:LINETO{x (-.25*sqrt(10 + (2*sqrt(5)))) y (.25*(sqrt(5) - 1))}
  12:LINETO{x (-.25*sqrt(10 - (2*sqrt(5)))) y (-.25*(sqrt(5) + 1))}
  13:LINETO{x (.25*sqrt(10 - (2*sqrt(5)))) y (-.25*(sqrt(5) + 1))}
  14:LINETO{x (.25 * sqrt(10 + (2  * sqrt(5)))) y (.25 * (sqrt(5) - 1))}
  15:CLOSEPOLY{}
  16:STROKE{b 0.1}
  17:}


2 comments:

  1. That's really good! Looks like the sign on the front of our car.

    ReplyDelete
  2. Just take a look at what followed (I've got a habit of blogging whilst I'm still experimenting, only keeping the best bits on line).

    ReplyDelete

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