Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Using Paths (1.2)
◄About Section► ◄Function Group► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
Using Paths
You can use path functions to perform the following tasks:
♦ Draw a geometric line.
♦ Draw a filled polygon.
♦ Create a clip path.
Drawing a Geometric Line
To draw a geometric line, you must perform the following steps:
1 Set the geometric-line width by calling the GpiSetLineWidthGeom
function.
2 Set the geometric-line-end style calling the GpiSetLineEnd function.
3 Start a path by calling the GpiBeginPath function.
4 Draw the line(s) by calling the GpiMove and GpiLine functions.
5 End the path by calling the GpiEndPath function.
6 Draw the line by calling the GpiStrokePath function.
The following code fragment shows how to draw a straight line that is 10
units wide and has round ends:
GpiSetLineWidthGeom(hps, 10L); /* sets line width to 10 */
GpiSetLineEnd(hps, LINEEND_ROUND); /* sets line end to round */
GpiBeginPath(hps, 1L); /* begins path */
ptl.x = 7; ptl.y = 15;
GpiMove(hps, &ptl); /* sets current position */
ptl.x = 450; ptl.y = 15;
GpiLine(hps, &ptl); /* draws line */
GpiEndPath(hps); /* ends path */
GpiStrokePath(hps, 1L, 0L); /* draws wide line */
Drawing a Filled Polygon
To draw a filled polygon, you must perform the following steps:
1 Start a path by calling the GpiBeginPath function.
2 Move to the starting point by calling the GpiMove function.
3 Draw the boundary lines by calling the appropriate line-drawing
function.
4 End the path by calling the GpiEndPath function.
5 Specify a fill mode and fill the path by calling the GpiFillPath
function.
The following code fragment shows how to draw an empty triangle within a
solid rectangle:
POINTL aptl1 [4] = { /* array of points for triangle */
50, 50,
100, 100,
150, 50,
50, 50 };
POINTL aptl2[5] = { /* array of points for rectangle */
25, 25,
25, 200,
200, 200,
200, 25,
25, 25 };
GpiBeginPath(hps, 1L); /* begins path */
GpiMove(hps, aptl1); /* sets current position */
GpiPolyLine(hps, 4,
aptl1); /* plots points for triangle */
GpiMove(hps, aptl2); /* sets current position */
GpiPolyLine(hps, 5,
aptl2); /* plots points for rectangle */
GpiEndPath(hps); /* ends path */
GpiFillPath(hps, 1L,
FPATH_ALTERNATE); /* draws triangle and rectangle */
Creating a Clip Path
To create a clip path, you must perform the following steps:
1 Start a path by calling the GpiBeginPath function.
2 Draw the border of the path by calling the appropriate line or arc
functions.
3 End the path by calling the GpiEndPath function.
4 Create the clip path by calling the GpiSetClipPath function.
The following code fragment shows how to create a triangular clip path and
then write text into it:
POINTL aptl[4] = { /* array of points for triangle */
35, 45,
100, 100,
200, 45,
35, 45 };
GpiBeginPath(hps, 1L); /* begins path bracket */
GpiMove(hps, aptl); /* sets current position */
GpiPolyLine(hps, 4, aptl); /* plots points for triangle */
GpiEndPath(hps); /* ends path bracket */
GpiSetClipPath(hps, 1L, SCP_ALTERNATE | SCP_AND); /* sets clip path */
ptlStart.x = 50;
for (i = 50; i < 110; i = i + 10) {
ptlStart.y = i;
/* write the text */
GpiCharStringAt(hps, &ptlStart, 18, "?!String of text!?");
}
♦