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

Friday, 19 June 2009

Avoiding Inifinite Recursions

It seems the usual way to avoid infinite recursions in context free art is to ensure that elements in your drawing tend toward zero size. Another perhaps less subtle way is make use of the weighting and have a low probability outcome as an empty rule as I have done here:-

startshape iris
background {b -1 }
rule iris {
draw{ hue 180 sat .5 }

rule draw {
CIRCLE{ b +1 hue 200}
SQUARE{s .5 b +1 x 2}
draw{r 10 s +1 hue -1 x +.2}
// ensure we terminate
rule draw .0001{}

Without the low probability rule you can watch the image getting bigger, and at some stage intermediate results are saved to file and so it goes on until you run out of memory.

No comments:

Post a Comment


Blog Archive

About Me

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