Graphics Functions: Draw a polygon using the current graphics color, logical write mode, and line style.
Module: USE IFQWIN
Syntax
result = POLYGON (control, ppoints, cpoints)
result = POLYGON_W (control, wppoints, cpoints)
control
(Input) INTEGER(2). Fill flag. One of the following symbolic constants (defined in IFQWIN.F90
):
ppoints
(Input) Derived type xycoord
. Array of derived types defining the polygon vertices in viewport coordinates. The derived type xycoord
is defined in IFQWIN.F90
as follows:
TYPE xycoord
INTEGER(2) xcoord
INTEGER(2) ycoord
END TYPE xycoord
cpoints
(Input) INTEGER(2). Number of polygon vertices.
wppoints
(Input) Derived type wxycoord
. Array of derived types defining the polygon vertices in window coordinates. The derived type wxycoord
is defined in IFQWIN.F90
as follows:
TYPE wxycoord
REAL(8) wx
REAL(8) wy
END TYPE wxycoord
Results
The result type is INTEGER(2). The result is nonzero if anything is drawn; otherwise, 0.
The border of the polygon is drawn in the current graphics color, logical write mode, and line style, set with SETCOLORRGB, SETWRITEMODE, and SETLINESTYLE, respectively. The POLYGON routine uses the viewport-coordinate system (expressed in xycoord
derived types), and the POLYGON_W routine uses real-valued window coordinates (expressed in wxycoord
types).
The arguments ppoints and wppoints are arrays whose elements are xycoord
or wxycoord
derived types. Each element specifies one of the polygon's vertices. The argument cpoints is the number of elements (the number of vertices) in the ppoints or wppoints array.
Note that POLYGON draws between the vertices in their order in the array. Therefore, when drawing outlines, skeletal figures, or any other figure that is not filled, you need to be careful about the order of the vertices. If you don't want lines between some vertices, you may need to repeat vertices to make the drawing backtrack and go to another vertex to avoid drawing across your figure. Also, POLYGON draws a line from the last specified vertex back to the first vertex.
If you fill the polygon using FLOODFILLRGB, the polygon must be bordered by a solid line style. Line style is solid by default and can be changed with SETLINESTYLE.
The POLYGON routine described here is a QuickWin routine. If you are trying to use the Microsoft* Platform SDK version of the Polygon routine by including the IFWIN module, you need to specify the routine name as MSFWIN$Polygon. For more information, see Building Applications: Special Naming Convention for Certain QuickWin and Win32 Graphics Routines.
Compatibility
STANDARD GRAPHICS QUICKWIN GRAPHICS LIB
See Also
SETCOLORRGB, SETFILLMASK, SETLINESTYLE, FLOODFILLRGB, GRSTATUS, LINETO, RECTANGLE, SETWRITEMODE
Example
! Build as a Graphics App.
!
! Draw a skeletal box
USE IFQWIN
INTEGER(2) status
TYPE (xycoord) poly(12)
! Set up box vertices in order they will be drawn, &
! repeating some to avoid unwanted lines across box
poly(1)%xcoord = 50
poly(1)%ycoord = 80
poly(2)%xcoord = 85
poly(2)%ycoord = 35
poly(3)%xcoord = 185
poly(3)%ycoord = 35
poly(4)%xcoord = 150
poly(4)%ycoord = 80
poly(5)%xcoord = 50
poly(5)%ycoord = 80
poly(6)%xcoord = 50
poly(6)%ycoord = 180
poly(7)%xcoord = 150
poly(7)%ycoord = 180
poly(8)%xcoord = 185
poly(8)%ycoord = 135
poly(9)%xcoord = 185
poly(9)%ycoord = 35
poly(10)%xcoord = 150
poly(10)%ycoord = 80
poly(11)%xcoord = 150
poly(11)%ycoord = 180
poly(12)%xcoord = 150
poly(12)%ycoord = 80
status = SETCOLORRGB(Z'0000FF')
status = POLYGON($GBORDER, poly, INT2(12))
END