Recursion

From CodeStuff
Revision as of 09:07, 13 August 2015 by Lerc (Talk | contribs)

Jump to: navigation, search


This program draws a thing by drawing five lines. Across-Up-Across-Down-Across. It's like a horizontal line with a kink in the middle.

What would happen if we replaced the three horizontal lines in drawThing with a horizontal line with a kink by using drawThing to draw itself.

Instead of drawLine(x,y,x+size,y) do drawThing(x,y,size/3);

Instead of drawLine(x+size,y-size,x+size*2,y-size) do drawThing(x+size,y-size,size/3);

Instead of drawLine(x+size*2,y,x+size*3,y) do drawThing(x+size*2,y,size/3);