|
|
Listing 16.1 contains the outline of the format for most of the examples in this chapter that will help you visualize the flow of logic that underlies the code.
Listing 16.1 A high-level code template for this chapter
// global variables here... function init(event) { // initialization here... initializeTriangle(); } function initializeTriangle() { drawPattern(level, xPts, yPts); } // initializeTriangle function drawPattern(level, oldXPts, oldYPts) { if( level >= 0 ) { // assign values to newXPts and newYPts // and then do some more things here... gcNode.appendChild(triangleNode); drawPattern(level-1, newXPts, newYPts); } } // drawPattern
Listing 16.1 can be summarized in the following manner: 'repeatedly invoke the function drawPattern() until some condition is no longer true.' Note that although this listing contains references to triangleNode and initializeTriangle(), you are obviously not restricted to triangles; in general, these entities can be replaced by polygons or other geometric objects of your choice.
|
|