**Recursive graphics: The Sierpinski Triangle**

The Sierpinski triangle is a very nice example of a recursive
pattern (fractal). It was described by the mathematician Sierpinski in
1915. Although it looks complex, it can be generated with a very short
*recursive* method.

First, let's try to understand the recursion.

Do you see the pattern? Imagine that you have a method called

//draws a black-filled triangle with vertices (x1, y1), (x2,y2), (x3,y3) drawFilledTriangle(int x1, int y1, int x2, int y2, int x3, int y3)When

//draws a Sierpinski triangle with vertices (x1, y1), (x2, y2), (x3, y3) render(int x1, int y1, int x2, int y2, int x3, int y3, int depth) { ... }

FractalDriver.java

Sierpinski.java