The routines for drawing multiple straight lines are:
gDrawPolylineTo2D(npts, points2)where points2 is an array of structures of type GPOINT containing two real elements (points2.x and points2.y).
For example - to draw the six lines shown in the figure below, an array points of type GPOINT is initialized with six coordinate pairs as appropriate to the language:
[C/C++] static GPOINT pt[6] = {2.0,1.0, 6.0,1.0, 8.0,3.0,
                       0.0,3.0, 4.0,7.0, 4.0,3.0};
      .
/* Move to start */
      gMoveTo2D(0.0,3.0);
/* Draw figure */
      gDrawPolylineTo2D(6,pt);
[F90] type (GPOINT), dimension(6) :: pt = (/ &
      GPOINT(2.0,1.0), GPOINT(6.0,1.0), GPOINT(8.0,3.0), &
      GPOINT(0.0,3.0), GPOINT(4.0,7.0), GPOINT(4.0,3.0) /)
      .
! Move to start
     call gMoveTo2D(0.0,3.0)
! Draw figure
     call gDrawPolylineTo2D(6,pt)
![]() |
Multiple Line Drawn by gDrawpolylineTo2D() |
The same figure could have been produced using the routine gDrawPolylineBy2D() as follows:
[C/C++] static GPOINT pt[6] = {2.0,-2.0, 4.0,0.0, 2.0,2.0,
                      -8.0,0.0, 4.0,4.0, 0.0,-4.0};
      .
/* Move to start */
      gMoveTo2D(0.0,3.0);
/* Draw figure */
      gDrawPolylineBy2D(6,pt);
[F90] type (GPOINT), dimension(6) :: pt = (/ &
      GPOINT{2.0,-2.0), GPOINT(4.0,0.0), GPOINT(2.0,2.0), &
      GPOINT(-8.0,0.0), GPOINT(4.0,4.0), GPOINT(0.0,-4.0} /)
      .
! Move to start
     call gMoveTo2D(0.0,3.0)
! Draw figure
     call gDrawPolylineBy2D(6,pt)