Dashed Lines

Fastgraph includes four functions for drawing dashed lines. All of them draw lines in the current color value and observe the clipping limits. The fg_dash() function draws a dashed line from the current graphics cursor position to an absolute screen space position, while fg_dashw() draws a dashed line to an absolute world space position. The fg_dashrel() function draws a dashed line from the current graphics cursor position to a screen space position relative to it. The fg_dashrw() function does the same in world space.

Each of these functions has three parameters. The first two specify the (x,y) coordinates of the destination position. For the screen space functions, these parameters are integer quantities. For the world space functions, these parameters are floating point quantities. The third parameter is a 16-bit pattern that defines the appearance of the dashed line. Bits that are set in the pattern produce the visible part of the line, while bits that are zero produce the invisible part. This pattern is repeated as necessary to draw the entire line. For example, the pattern value 3333 hex would produce a dashed line with the first two pixels off, the next two on, the next two off, and so forth. Similarly, the pattern value FFFF hex would produce a solid line.

The destination position passed to any of the dashed line functions becomes the new graphics cursor position. This makes it possible to draw connected dashed lines without calling a graphics cursor movement function between successive calls to a line drawing function.

The following code draws the pair of crossed dashed lines that divide the active virtual buffer into quadrants, similar to what we did with solid lines in the previous section. It does this using fg_move() and fg_dash(), with a dash pattern of 3333 hex (which alternates two pixels off and two pixels on).





Visual Basic:

Call fg_move(mid_x, 0)
Call fg_dash(mid_x, max_y, &H3333)
Call fg_move(0, mid_y)
Call fg_dash(max_x, mid_y, &H3333)

<< Prev

Next >>

Fastgraph Home Page


copyright 2001 Ted Gruber Software, Inc.