Circles, Ellipses, and ArcsFastgraph includes functions for drawing filled and unfilled circles and ellipses, plus unfilled circular arcs. Both screen space and world space versions of these functions are available, and all of them observe the clipping limits. The fg_circle() function draws an unfilled circle in screen space, centered at the graphics cursor position, using the current color. Its only parameter specifies the circle's radius in horizontal screen space units. Another function, fg_circlew(), draws an unfilled circle where the radius is measured in horizontal world space units. The analogous functions for drawing filled circles are fg_circlef() and fg_circlefw(). All four circle drawing functions leave the graphics cursor position unchanged. The fg_ellipse() function draws an unfilled ellipse in screen space, centered at the graphics cursor position, using the current color. The function requires two parameters that respectively specify the length of its horizontal and vertical semi-axes. In other words, the first parameter is the absolute distance from the center of the ellipse to its horizontal extremity, and the second parameter is the absolute distance from the center to the vertical extremity. Another function, fg_ellipsew(), draws an unfilled ellipse in world space. The analogous functions for drawing filled ellipses are fg_ellipsef() and fg_ellipsfw(). All four ellipse drawing functions leave the graphics cursor position unchanged. The following code snippet illustrates the use of fg_circlew() and fg_ellipsew() in a 200x200 world space coordinate system.
C/C++ and Delphi:
Visual Basic:
We first draw an ellipse and then draw a circle, both centered at the middle of the virtual buffer (which is the origin of our world space coordinate system). The circle has a radius of 1/16 the width of the virtual buffer (in this case, 12.5 horizontal world space units), and the ellipse is horizontally inscribed within the circle. We can do the same thing in screen space with fg_circle() and fg_ellipse(), as shown here:
C/C++:
Delphi:
Visual Basic:
Note that in this case, the fg_circle() and fg_ellipse() parameters are dependent on the maximum x and y coordinates of the active virtual buffer. If we didn't compute these quantities in this manner, the actual size of the circle and ellipse would be proportional to the virtual buffer resolution. No such dependency exists when using world space, but we pay a price for this feature in slightly slower execution speed. The fg_arc() function draws an unfilled circular arc in screen space, centered at the graphics cursor position, using the current color. Its first parameter specifies the arc's radius in horizontal screen space units (that is, the arc's horizontal distance at zero degrees from the current graphics position). The two remaining parameters define the starting and ending points of the arc, expressed in tenths of degrees counterclockwise from the horizontal. For example, we could construct a circle with a 30-pixel radius from four 90º arcs, each in a different color, as shown here:
C/C++ and Delphi:
Visual Basic:
Another function, fg_arcw(), draws an arc where the radius is measured in horizontal world space units. Both arc functions draw the arc counterclockwise from the starting angle to the ending angle and leave the graphics cursor position unchanged. It's important to note that the circle, ellipse, and arc functions draw these shapes with aspect ratios for the active virtual buffer. For example, a circle will appear circular in the virtual buffer, but it will be transformed into an ellipse if you scale the virtual buffer contents in the client area with fg_vbscale() unless the client has the same aspect ratio as the virtual buffer. Similarly, the aspect ratio of an ellipse or arc may become distorted under these same circumstances. You can avoid these problems by using fg_vbpaste(), or by making sure the size of the client area can only change in increments that maintain the same aspect ratio as the active virtual buffer.
|
 
copyright 2001 Ted Gruber Software, Inc.