Recursion

From CodeStuff
Revision as of 08:58, 13 August 2015 by Lerc (Talk | contribs) (Created page with "<edcode> function drawThing(x,y,size) { if (size < 1) return; //do nothing if the size is tiny drawLine(x,y,x+size,y); drawLine(x+size,y,x+size,y-size); drawLi...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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);