• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

JSP for Scripting

As we saw in Chapter 18, “Server-Side Basics,” serving up SVG using Java Server Pages (JSP) is only a matter of specifying the appropriate MIME type and then listing the SVG content. There isn't much point in doing so unless some use is made of the Java programming language, and the simplest way of using JSP to dynamically generate SVG is to treat it as a scripting language.

SVG Fractals

Unfortunately, many of the appealing images that are loosely categorized as “fractals” are pixel-based, which means that they aren't a very good fit for a vector-based system like SVG. However, many are produced by repeatedly applying an affine transformation to a simple shape. Such transformations are combinations of linear operations such as translation, rotation, and reflection, and SVG is good at shapes and can do these operations. One such fractal image is the Sierpinsky Triangle. It is formed by initially drawing a triangle and then applying a scaling and translation transformation three times to produce three new triangles, located at the corner positions of the original shape. The scaling and triplication is then repeated for as many times as required (see Figure 19.1).


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint