I recently came across this beautiful generative art piece, **’Trunk’ by Kjetil Golid** (source code).

I went through the code and understand what’s being done, yet I’m unable to grasp why the algorithm works the way it does. Can someone explain it to me?

I even ported it to Java from Javascript, in case any of you would like to run it without having to set up an html page. I 've also annotated all the variables that made sense to me.

```
int rings = 50; // number of rings
float dim_init = 50; // size of innermost ring
float dim_delta = 4; // distance between two adjacent rings
float chaos_init = 0.2; // noise on innermost ring
float chaos_delta = 0.12; // change in ring noise as you move outwards
int chaos_mag = 20; // magnitude of noise
float ox = random(10000);
float oy = random(10000);
float oz = random(10000);
void setup() {
size(700, 700);
frameRate(60);
smooth();
strokeWeight(1);
stroke(0);
noFill();
}
void draw() {
clear();
background(255, 255, 255);
translate(width/2, height/2);
//ox += 0.04;
oy -= 0.02;
oz += 0.01;
for (int i=0; i<rings; i++) {
beginShape();
for(int angle=0; angle<360; angle++){
float radian = radians(angle);
//stroke(map(angle, 0, 360, 255, 0), map(i, 0, rings, 255, 0 ), map(angle*i, 0, 360*rings, 255, 0));
float radius = (chaos_mag*getNoiseWithTime(radian, chaos_delta*i+chaos_init, oz)) + (dim_delta*i+dim_init);
vertex(radius*cos(radian), radius*sin(radian));
}
endShape(CLOSE);
}
}
float getNoiseWithTime(float radian, float dim, float time) {
float r = radian % TWO_PI; // r repeats every 360 degrees
if (r<0) {r += TWO_PI;}
return noise(ox+cos(r)*dim, oy+sin(r)*dim, oz+time);
}
```