Code: Processing

Very simple recursive function, ideal for fractal like object generation:


interact by moving the mouse left to right

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.



code:



void setup()
{
size(500,500,P3D);
fill(255);
noStroke();
frameRate(30);

}
float r=0;
float th=360/8.;
float t=0;
float d=-10;
float theta=10;
float ttheta=theta;
float mx=10;
float nyu=2.5;
float dev=0.6;

void draw()
{
lights();
ttheta=mouseX/10.;
theta+=(ttheta-theta)/30.;
background(255);
translate(width/2,height/2+60);
rotateY(r);
r+=(PI/180.*0.7);
scale(1);
elem(mx);
}


void elem(float r)
{
r*=dev;
if (r>1)
{
stroke(0);
line(0,0,0,d);
pushMatrix();

translate(0,d);
scale(pow(r,2.2)/mx);
noStroke();
box(r*2);
for (int i=0;i<360;i+=th)
{
rotateY(radians(i));
//scale(0.93);
pushMatrix();
rotateZ(-PI/180.*theta);
elem(r);
popMatrix();
}
popMatrix();
}
}



Comments are not available for this entry.