This program draws two ducks in different viewports on the same display surface (see ). As well as the polyline and fill area primitives, it also uses polymarkers and text. The position and size of the text are determined by setting the character up vector and the character height. The workstation selected in this example is the Hewlett Packard 7470A 2 pen plotter.
PROGRAM DUCK INCLUDE 'GKS$GTSDEV' INCLUDE 'GKS$ENUM' INTEGER errfil, wkid PARAMETER(errfil = 10, wkid = 1) REAL pxa(44), pya(44) INTEGER asflst(1:13) DATA pxa/0.0,2.0,4.0,6.0,8.0,10.0,12.0,14.0, * 16.4,17.0,17.3,17.8,18.5,20.0,22.0,24.0, * 26.0,28.0,29.0,28.8,27.2,25.0,23.0,21.5, * 21.1,21.5,22.8,24.1,25.1,25.2,24.2,22.1, * 20.0,18.0,16.0,14.0,12.0,10.0,8.0,6.1, * 4.2,3.0,1.3,0.0/ DATA pya/8.8,7.6,7.1,7.4,8.0,8.9,9.6,9.9, * 9.4,9.7,12.0,14.0,16.1,17.0,17.0,16.0, * 13.9,13.1,13.2,12.3,11.5,11.5,11.5,11.2, * 10.5,9.0,8.0,7.0,5.1,3.6,1.9,1.1, * 0.9,0.7,0.8,1.0,1.0,1.2,1.8,2.1, * 2.9,4.1,6.0,8.8/ DATA asflst /13 * gindiv/ ! set all ASFs C CALL gopks(errfil, 0) ! open gks (BUFA not used) CALL gopwk(wkid, 6, H475L4) ! open workstation CALL gsasf(asflst) ! set attributes individually CALL gacwk(wkid) ! activate workstation C CALL gstxfp(1, gstrkp) ! set font 1, stroke precision CALL gschh(1.5) ! set char. height C C... Set Normalization Transformation C CALL gswn(1, 0.0,30.0,0.0, 30.0)! set window CALL gsvp(1, 0.0, 0.5, 0.0, 0.4)! set viewport in lower left CALL gselnt(1) C CALL gsln(glsoli) ! set solid line type CALL gpl(44, pxa, pya) ! polyline CALL gsfais(ghatch) ! set hatch fill area CALL gfa(44, pxa, pya) ! fill area CALL gschup(-1.0, 8.0) ! set char. up vector CALL gtx(8.0, 20.0, '"Quack"') ! text at position 8,20 C C... Re-Set Normalization Transformation C CALL gsvp(1, 0.5, 1.0, 0.4, 0.8)! move vpt to upper right CALL gsmk(gast) ! set asterisk marker type CALL gpm(44, pxa, pya) ! polymarker CALL gsfais(gsolid) ! set solid fill area CALL gfa(44, pxa, pya) ! fill area CALL gschup(0.5, 1.0) ! reset char. up vector CALL gtx(7.0, 20.0, '"Quack"') ! text at position 8,20 C CALL gdawk(wkid) ! deactivate workstation CALL gclwk(wkid) ! close workstation CALL gclks ! close GKS END
Figure: Output produced by example 'Ducks'