Unfilled Rectangles

Fastgraph includes four functions for drawing unfilled rectangles. The fg_box() function draws an unfilled rectangle in screen space, with regard to the clipping limits, using the current color. The parameters to fg_box() are the same as those for fg_rect(). The depth of the rectangle's edges is one pixel by default, but you can change the depth by calling fg_boxdepth(). The fg_boxdepth() function expects two parameters. The first parameter is the width of the rectangle's left and right sides, while the second is the height of its top and bottom sides. Once you call fg_boxdepth(), fg_box() draws all unfilled rectangles using the depth values specified in the most recent call to fg_boxdepth(). The fg_getxbox() and fg_getybox() functions respectively return the horizontal and vertical box depth settings, as defined in the most recent call to fg_boxdepth(). The world space box-drawing function is fg_boxw().

The fg_boxx() and fg_boxxw() functions are screen space and world space "exclusive or" versions of the box drawing functions. They simplify displaying rubberband boxes (hollow rectangles that move in response to keystrokes or mouse movement) because drawing an object in XOR mode makes it appear, but drawing it again in the same position and in the same color restores what was under the object originally. Given this useful property, here is an outline of what's necessary to draw a rubberband box:

  1. Draw the box in its initial position with fg_boxx() or fg_boxxw(), and copy the virtual buffer contents to the client area.

  2. Wait for a user response that signifies box movement.

  3. Use fg_boxx() or fg_boxxw() to redraw the box in the same position as in step 1, then copy the virtual buffer contents to the client area. This restores what was there originally.

  4. Draw the box in its new position with fg_boxx() or fg_boxxw(), and copy the virtual buffer contents to the client area.

  5. Repeat steps 2, 3, and 4 until the box is no longer needed.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.