top of page

Fractals  
Let's generate some textures!

This is a recursive algorithm that uses the rotate() function. Every time the drawUnit function is called with a set of parameters, it calls itself until a condition is no longer satisfied. The parameters include a number called n which controls the speed of the self-calling function finishing its cycle. And the n will be updated before the self-calling function is called the next time.  

The screen shows basically rotating lines. The rotating angle and speed will change. The lines gradually come together. 

Rotate()

function draw() {
  background(180);
  angleMode(DEGREES);
 
 
  translate(width/2,height/2);       
//rotation center
  rotate(20);                         //clockwise
  line(0,0,0,height/2+50);            //relative to the rotation center
  rotate(20);                         //based on previous rotate
  line(0,0,0,height/2+50);    

}

bottom of page