Chapter 16: ECMAScript, Recursion, and SVG

   



High-Level Template for Code Examples

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

start example
// 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 
end example

Remarks

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.



   



Fundamentals of SVG Programming. Concepts to Source Code
Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)
ISBN: 1584502983
EAN: 2147483647
Year: 2003
Pages: 362

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net