CHAPTER 4 Structured Graphics

What are structured graphics?


The term "structured graphics" refers to graphics (figures) that are composed into a data structure. The graphics are drawn on the screen when the structure is traversed. Contrast this with "immediate mode" graphics where geometric shapes are drawn directly on the screen. (No data structure traversal is involved.) Fresco supports both structured and immediate mode graphics. In fact, in order to draw themselves, figures use the immediate mode graphics provided by Fresco's Painter object.

Let's take a look at the "structure" part of structured graphics. In Fresco, this data structure is a directed acyclic graph (DAG) made up of glyphs. Since figures are glyphs, they fit right into a DAG of other glyphs, including the viewers, boxes, and layout glyphs discussed in previous chapters.

Figure 4-2 shows the glyph structure implemented in the Figgy program in the file figgy.cxx.

Actually, the Figgy program really doesn't take advantage of the power of Fresco's structured graphics. For example, notice in figure 4-2 above that all the created figures are in a single level below the root PolyFigure. Fresco, on the other hand, allows creating arbitrary multi-level structures. A simple two-level graphics structure is shown in figure 4-3. Here, the wheels are created by grouping a collection of circles and polygons.

Fresco also provides the ability to instance or share figures (or indeed, any type of glyph.) Figure 4-4 shows a drawing that appears on the display to be the same as that shown in figure 4-3, but that in fact has an altogether different glyph structure--one that takes advantage of sharing. Here there is only a single wheel in the drawing, yet it appears twice on the display. One advantage of sharing is that it saves memory. Another is in what it means when a wheel is modified. In figure 4-3, individual wheels can be transformed (for example, scaled or rotated) by changing the transformation matrix stored by the individual group (PolyFigure). In figure 4-4, on the other hand, changing the group's transformation matrix will change both wheels. For example, scaling this transform by a factor of 1.5 will cause both wheels to appear half-again larger on the display. In order to transform the individual wheels in figure 4-4, you must change the transformation matrix of the individual instance glyph.

The simple Figgy program does not provide the ability to either group or instance graphical objects. Its more sophisticated cousin Fdraw (see chapter 1), however, provides both capabilities. Like Figgy, the Fdraw program and source code are included in the Fresco release.


Copyright (c) 1994 by Steve Churchill
Comments or questions? Contact Steve Churchill (stevec@faslab.com)

Generated with CERN WebMaker