
Fresco Tutorial

In this chapter we examine Fresco's structured graphics using an example called Figgy, shown running in figure 4-1, which is implemented in less than 200 lines of C++ code. Let's start by examining the application.
Circles and squares are created in Figgy by pressing the left mouse button. Pressing it the first time creates a circle. Pressing it again creates a square (rectangle). The program toggles between creating circles and squares with each mouse click.
In Fresco, we call graphical objects like circles and rectangles "figures". To move one of the circles created, place the mouse above the figure, click the left button, and then drag it to a new position. The Control key is used to move (scroll) the entire drawing. This is done by (1) placing the mouse cursor above white space (any position where there's no circle or square) (2) holding down the Control key, and then (3) pressing the left mouse button and dragging.
The figures can be scaled using the Shift key by clicking on a figure and then dragging the mouse. This causes a figure to scale about its own center. The entire drawing can be scaled by holding the Shift key while clicking and dragging over white-space. This can be thought of as zooming in and out on the drawing.
Although the Figgy program is simple (again, about 200 lines of C++) it exercises behavior common in drawing programs employing structured graphics--the ability to directly manipulate (for example, drag and scale) graphical objects, and the ability to scroll and zoom the drawing. The Figgy program is publicly available in the file figgy.cxx in Fresco's tutorial directory. Web users can obtain Fresco via http://www.x.org under "current projects". As we examine how the Figgy program works, we'll learn about draw traversal in Fresco as well as pick traversal, event handling and graphical transformations. To start, let's examine what is meant by the term "structured graphics".
Generated with CERN WebMaker