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

Tuesday, 11 August 2009

A processing spiral using recursion

Not as smooth as the context free version, but here is my nautilus like shell curve, using recursion in a processing applet.
   1:float REDUCE = 0.999;  
2:float MIN_SIZE = 0.8; // about right for processing
3:
4:void setup(){
5: size(400, 400);
6: translate(100, 330);
7: rotate(0.3);
8: fill(255, 0, 0, 0);
9: background(0);
10: noStroke();
11: smooth();
12: fill(255, 0, 0, 20); // transparency makes for almost '3d' look
13: shell(-0.008, 1.5, 25);
14:}
15:
16:void shell(float rot, float disp, float sz){
17: if (sz < MIN_SIZE){
18: print("done");
19: }
20: else{
21: sz *= REDUCE;
22: disp *= REDUCE;
23: translate(disp, 0);
24: rotate(rot);
25: ellipse(disp, 0, sz, sz);
26: shell(rot, disp, sz); // recursive call
27: }
28:}


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