The basic line-drawing command consists in the specification of a starting address on the raster of the output medium and then the instruction to draw a straight line segment from the cell with this address to the cell having a specified finishing address. In the SMOG system the issuing of a starting address causes nothing to be drawn, the instruction is output to the device and a current plotting position pointer - (XP,YP) for brevity in this text - is reset. The device awaits the completion of the command which can be the line segment instruction as above or the plotting of a "Point" or other graphic character as part of the picture.
The subroutines to be described here take the coordinate number specifications by the user to be cell addresses in the raster of the device. If the user has selected Region 1 then the numbers will usually be scaled and the resulting "Point" translated before rounding and assigning to type INTEGER to indicate an addressable cell. If Region 0 is selected, the user's coordinate numbers will be assigned to type INTEGER variables immediately and the nearest raster cell to the indicated "Point" will be addressed. In both cases direct addressing of the raster is performed.
SET(X,Y) JSETXY(IX,IY)
resets (XP,YP) to (X,Y), no plotting takes place.
TOXY(X,Y) JTO(IX,IY)
draws the line segment from (XP,YP) to (X,Y) and resets (XP,YP) to (X,Y). A sequence of calls to this subroutine can thus be used to draw the approximation to a smooth, continuous curve.
VEC(X1,Y1,X2,Y2) JVEC(IX1,IY1,IX2,IY2)
draws the line segment from (X1,Y1) to (X2,Y2) using the above two instructions and resets (XP,YP) to (X2,Y2). Redundancy in the resulting machine-coded instructions can be reduced, where context permits, by use of the following four subroutines:
SETX(X) JSET(IX)
resets (XP,YP) to (X,YP)
SETY(Y) JSET(IY)
resets (XP,YP) to (XP,Y)
TOX(X) JTOX(IX)
draws the line segment from (XP,YP) to (X,YP), resets (XP,YP) to (X,YP)
TOY(Y) JTOY(IY)
draws the line segment from (XP,YP) to (XP,Y), resets (XP,YP) to (XP,Y).
Example: SMOG Interpretation 4.1.8
CALL HPACK Select pen-plotter CALL LIMIT(-3.2,-1.1,3.2,1.1) Set scales to whole area A=3.1416 B=0.02*A CALL SETXY(A,0.0) (XP,YP)=(3.141.6,0.0) DO 10 I=1,100 draw ... CALL TOXY(A,SIN(A)) A=A-B 10 CONTINUE ... curve CALL ADVFLM new frame CALL ENDSPR end graphics
Note: (i) Region 1 was selected automatically by CALL HPACK
(ii) CALL HPACK and CALL ENDSPR are the necessary delimiters.
VECFAM(X1,Y1,X2,Y2,X3,Y3,X4,Y4,N) JVECFM(IX1,IY1,IX2,IY2,IX3,IY3,IX4,IY4,N)
This vector family routine draws the two lines (X1,Y1) to (X2,Y2) and (X3,Y3) to (X4,Y4) and draws N-1 lines between these two. The N-1 lines are such as to partition the space between the two lines into N equal areas. The lines are of the form:
(X1+α(X3-X1),Y1+α(Y3-Y1)) to (X2+α(X4-X2),Y2+α(Y4- Y2)) where 0<α<1
The two lines can be in any direction and may intersect. For example, if (X1,Y1) = (X3,Y3), a fan of lines is produced. Of course, spacing between lines will not be constant along their length and so a coloured fan would vary in brightness. This routine does not update the current point; its value is the same on exit as it was on entry.
Two high-level routines use the vector family to draw a graticule over a rectangular area defined by two parallel lines:
HGRATX(X1,Y1,X2,Y2,N)
draws the two extreme line segments:
l1 from (X1,Y1) to (X1,Y2) and l2 from (X2,Y1) to X2,Y2);
the rectangular region defined by l1 and l2 is then partitioned by N-1 lines equally spaced and parallel to the Y axis in the selected Region. A grating or graticule is thus produced.
HGRATY(X1,Y1,X2,Y2,N)
draws N+1 lines as above but, in this case, the lines are parallel to the X-axis in the selected Region.
The subroutines in Section 4.1 all map the user's coordinate specifications to unique cells in the raster on the output medium. The cells are, as it were, directly addressed from the currently selected region. The next set of subroutines allows relative displacements from the current plotting position (XP,YP) and can be thought of as indirectly addressing the raster. The subroutine identifiers have the mnemonic "DX", "DY", "DXY" included to indicate their incremental nature. They find their greatest use to be in the definition of Files of picture information (see Section 7). These instructions, stored as command-sets in files, allow particular structures to be defined once only but used many times, often at different positions on the output medium:
UPDX(DX) JUPDX(IDX)
resets (XP,YP) to (XP+DX,YP)
UPDY(DY) JUPDY(IDY)
resets (XP,YP) to (XP,YP+DY)
UPDXY(DX,DY) JUPDXY(IDX,IDY)
resets (XP,YP) to (XP+DX,YP+DY)
TODX(DX) JTODX(IDX)
draws the line segment from (XP,YP) to (XP+DX,YP) and resets (XP,YP) to (XP+DX,YP)
TODY(DY) JTODY(IDY)
draws the line segment from (XP,YP) to (XP,YP+DY) and resets (XP,YP) to (XP,YP+DY)
TODXY(DX,DY) JTODXY(IDX,IDY)
draws the line segment from (XP,YP) to (XP+DX,YP+DY), resetting (XP,YP) to (XP+DX,YP+DY).
Since these subroutines have incremental effect the user should be aware of the possibility of plotting out of the visible area - often for no immediately apparent reason!
Example 4.2.7:
SUBROUTINE CIRCLE(RAD) C DRAW A CIRCLE, RADIUS "RAD" ABOUT C THE CURRENT PLOTTING POSITION(XP,YP). TH=0.0 PH=0.0 DTH=0.031416 CALL UPDX(RAD) DO 10 I=1,200 TH=TH+DTH DX=RAD*(COS(TH)-COS(PH)) DY=RAD*(SIN(TH)-SIN(PH)) CALL TODXY(DX.DY) 10 FH=TH CALL UPDX(-RAD) RETURN END
Note:
VECFAR(DX1,DY1,DX2,DY2,DX3,DY3,N) JVECFR(IDX1,IDY1,IDX2,IDY2,IDX3,IDY3,N)
This routine is a relative version of the VECFAM routine. The first point is assumed to be the current point (XP,YP) and the other points are all defined relative to this one. The routine draws the two lines (XP,YP) to (XP+DX1,YP+DY1) and (XP+DX2,YP+DY2) to (XP+DX3,YP+DY3) and N-1 lines in between.
This routine does not update the current point; its value is the same on exit as it was on entry.
The routines VECFAM and VECFAR should be used wherever possible to shade solid areas.