Java Reference
In-Depth Information
Figure 12.2
Sierpinski triangle, level 2
We apply this principle in a recursive manner. Just as we replaced the original tri-
angle with three inner triangles, we replace each of these three triangles with three
inner triangles to obtain Figure 12.3 with nine triangles in level 3:
Figure 12.3
Sierpinski triangle, level 3
This process continues indefinitely, making a more intricate pattern at each new
level. Figure 12.4 shows the result at level 7:
Figure 12.4
Sierpinski triangle, level 7
We can solve this problem using the DrawingPanel class from Supplement 3G.
We'll pass the Graphics object for the panel to the method that is to draw the
Search WWH ::




Custom Search