Contact us Heritage collections Image license terms
HOME ACL Associates Technology Literature Applications Society Software revisited
Further reading □ OverviewNo.1No.2No.3No.5No.6No.7No.8No.9No.10
ACD C&A INF CCD CISD Archives Contact us Heritage archives Image license terms

Search

   
ACLLiteratureProgress ReportsGraphics User Notes
ACLLiteratureProgress ReportsGraphics User Notes
ACL ACD C&A INF CCD CISD Archives
Further reading

Overview
No.1
No.2
No.3
No.5
No.6
No.7
No.8
No.9
No.10

Graphics User Note No 5: Shading in Areas

A H Francis

7 October 1976

5.1 INTRODUCTION

A set of routines is now available in the Graphics Algorithms Library which will scan an outline drawing and shade the area enclosed by it. The definition of the outline should be held in a 2-dimensional array as X,Y coordinate pairs. This shading is done by drawing vertical scan lines. The number of scan lines can be changed to vary the density of the shading and hence allow for the different raster sizes of the output devices. The outline should be closed, ie the first and last coordinate pair should be the same. If it is not closed, a line joining the last and first points will be assumed to close the outline and a warning message will be output. The outline can be any shape; it need not necessarily be convex and it may even cross itself. Areas which are enclosed by the outline an odd number of times are assumed to be 'inside' and will be shaded. Areas which are enclosed by the outline an even number of times are assumed to be 'outside' and will not be shaded.

The normal FORTRAN naming conventions for REAL and INTEGER variables apply.

5.2 USER ROUTINES

The coordinate pairs are usually held in an INTEGER array. The routine SCSZIN is used to set the scanning size, ie the range, and the scanning increment which controls the density. The routine SCANAR shades in the outline using these values. However, if the range of the coordinates is small, where small usually means considerably less than the number of scan lines required, they can be held in a REAL array. The routine PRSCAN can then be used to select a suitable scanning range, preprocess the data points and then shade in the outline. Otherwise, if the range of the coordinates is small the fact that integers are used in SCANAR may give undesirable results caused by rounding problems.

5.2.1 SCSZIN(ISIZE, INC)

This routine sets the size and increment for the scan. The scan size, ISIZE, is normally the same as the range of x-coordinate limits of the region (the lower limit normally being 0), in which the picture is to be drawn. The x coordinates of the scan lines will be integer values in the range 1 ≤ x ≤ ISIZE. Thus any part of the outline whose x coordinate is outside this range will not be drawn or scanned, The scanning increment, INC, controls the number of scan lines to be drawn. Only every INCth scan line of the ISIZE potential scan lines will be drawn, starting with the first. The total number of scan lines across the scanning area, ISIZE/INC, is the line density. The following table suggests suitable line densities for each output device to obtain solid shading over the full screen area.

Output Device             Line Density 
FR80 35mm                    1000
FR80 16mm                     500
FR80 Hardcopy (single)       1000
FR80 Hardcopy (2x2)           500
FR8O microfiche               500
Tektronix                     230
Hewlett Packard              1000 (not recommended)
Lineprinter graphical         120

5.2.2 SCANAR (N,IARR)

This routine shades in the outline described by the first N coordinate pairs held in the array IARR. This INTEGER array should be dimensioned (2,N), the X coordinates being held in the elements IARR(1,I) (I=I,N) and the Y coordinates being held in the elements IARR(2,I) (I=I,N). The shading will be done by drawing equally spaced vertical scan lines 'inside' the boundary. If these lines are sufficiently close together, the actual separation depending upon the output device being used (see 5.2.1), the shading will appear to be solid. Points defining the outline may be outside the x-range of the scanning ie IARR(1,I)≤0 or IARR(1,I)>ISIZE. However, only those parts of the outline within the scanning range will be shaded.

5.2.3 PRSCAN (XMIN,YMIN,XMAX,YMAX,N,ARR,IARR,INCR)

This routine shades in the outline described by the first N coordinate pairs of the array ARR. Both the arrays ARR and IARR should be dimensioned (2,N). The array ARR is of type REAL and contains the x and y coordinates of the data points. The array IARR is of type INTEGER and is used as work space. The arguments XMIN, YMIN, XMAX and YMAX specify the coordinate system of the data points in the array ARR, where the rectangle (XMIN,YMIN), (XMAX,YMAX) will represent the visible area. Normally, the data points should all be within the range XMIN≤ARR(1,I) ≤ XMAX, YMIN ≤ ARR(2,I) ≤ YMAX. The argument INCR specifies the number of raster points (see SMOG Manual 3.1) required between each scan line on the output device. Generally, a solid picture can be obtained on any of the FR80 cameras by drawing lines 12 raster points apart and on the Tektronix by drawing lines 4 raster points apart. The routine finds the number of device raster points (for SPROGS the first output device in the region chain is used) across the visible area and sets the limits for the visible area and the scan size to this number. The scanning increment is set to INCR and the data points in the array ARR are suitably scaled and held in the array IARR. The routine SCANAR is then called to scan the outline. Before control is returned to the user the limits of the visible area are reset to (XMIN,YMIN),(XMAX,MAX).

5.3 NOTES ON USE

(1) The package can be used with either SMOG or SPROGS.

(2) The number of points at which the outline changes its direction with respect to the x coordinate, ie points of the form < or > should not exceed 100. Also, the boundary should not have more than 50 intersections with any scan line.

(3) The routine SCSZIN does not set up a coordinate system. The user must set up his own coordinates system before calling SCANAR or PRSCAN.

(4) These routines can by careful construction of the outlines, be used to shade in objects which have 'holes' in them. For example, to shade in a washer, ie a circular 'hole' in the middle of a circular object, the outline of the outer circle can be connected to the outline of the inner circle by two similar straight lines in such a way that the whole boundary is closed (see diagram). Thus, the area inside the inner circle is actually outside the object to be scanned and provided that the two linking straight lines exactly coincide the required shaded in picture will be produced.

However, it is not always convenient to structure the data in this way. The SPROGS system which is available on the 1906A has facilities for shading in simultaneously, several areas which may be overlapping, with the hidden lines removed.

(5) The routines are accessible from the 1906A library file :GRAFLIB.GRAFLIB and this name must be included in a LIB parameter in a macro call.

On the 360/195 the routines are on autocall in SYS1.SMOG and so the ordinary JCL for running a SMOG job should be used.

(6) The package uses the following names which should be avoided by the user:

Routine names: 
PRSCAN,SCANAR,ARCREF,ARSCAN,ARCINT,SCSZIN,SCANBD 
Common block name: 
SCANCO, CLIBOP 

5.4 EXAMPLES

The two examples here illustrate the use of SCANAR and PRSCAN respectively. The first example shades in a 12 point star. The data describing the outline is generated by the program. Two frames of output are produced. The first has a line density (see 5.2.1) of approx 500 and appears solid. The second has a line density of approx 100 and has the individual scan lines clearly visible.

The second example generates a 4×4 black and white checkerboard pattern. The coordinates of the outline are data initialised in the array DAT and are all in the range 0.0 ≤ X,Y ≤ 1.0. The outline consists of a set of contiguous linked horizontal lines across the screen followed by a set of contiguous linked vertical lines up and down the screen (See exaggerated diagram.)

Since the range of the coordinates is small the routine PRSCAN is called. This fills the screen with the picture and shades it in with lines 12 rasters apart (ie it appears solid when outputting to the FR80). This example also shows that areas enclosed by the outline, an even number of times, such as the bottom left hand corner square which is enclosed twice, do not get shaded in. A surrounding rectangular box is then drawn for the edges of the board.

If the programs of the two examples are in files SCANEXl and SCANEX2 then the following SMOG calls can be used to run then on the 1906A.

SMOG *CR SCANEX1,LIB :GRAFLIB.GRAFLIB,JT30 
SMOG *CR SCANEX2,LIB :GRAFLIB.GRAFLIB,JT30 

On the 360/195 the ordinary JCL for running a SMOG job should be used to run the examples (note that the LIST and MASTER statements are 1906A specific and are irrelevant to the 360/195.)

5.4.1 Example 1

      LIST 
      MASTER ARSC 
      DIMENSION IARR(2,250) 
C SHADE IN ANN POINT STAR 
      CALL FRHCM 
      CALL APER 
C SELECT SCAN SIZE AND INCREMENT 
C TO GIVE LINE DENSITY OF 500 
      CALL SCSZIN(1024,2) 
      CALL JLIMS(0,0,1024,1024,1,1) 
      R=500.0 
      RL=250.0 
C SELECT NUMBER Of POINTS FOR STAR 
      N=12 
      PI=3.14159 
      ANGI=PI/Fl0AT(N) 
      ANG=0.0 
C SET FIRST POINT 
      IARR(1,1)=512 
      IARR(2,1)=1012 
C LOOP FOR OTHER POINTS 
      DO 10 I=1,N 
      ANG=ANG+ANG1 
      IARR(1,2*I)=RL*SIN(ANG)+512 
      IARR(2,2*1>=RL*COS(ANG)+512 
      ANG=ANG+ANGI 
      IARR(1,2*I+1)=R+SIN(ANG)+512 
      IARR(2,2*I+1)=R+COS(ANG)+512 
   10 CONTINUE 
C NUBER Of POINTS DESCRIBING OUTLINE IS 2*N+1 
      N=2*N+1 
C SCAN IN THE OUTLINE 
      CALL SCANAR(N,IARR) 
      CALL ADVFLM 
C CHANGE SCANNING INCREMENT TO EVERY 10TH LINE ANO SCAN 
      CALL SCSZIN(1024,10) 
      CALL SCANAR(N,IARR) 
      CALL ENDSPR 
      STOP AR 
      END 

5.4.2 Example 2

      LIST 
      MASTER CHES 
      DIMENSION DAT(2,20),IDAT(2,20) 
C   INITIALISE OUTLINE COORDINATE ARRAY 
      DATA DAT/0.0,1.0,1.0,1.0,1.0,0.75,0.0,0.75 
     1,0.0,0.5,1.0,0.5,1.0,0.25,0.0,0.25 
     2,0.0,0.0,1.0,0.0,1.0,1.0,0.75,1.0 
     3,0.75,0.0.0.5,0.0,0.5,1.0,0.25,1.0 
     4,0.25,0.0,0.0,0.0,0.0,1.0/ 
c   SELECT CAMERA AND VISIBLE AREA 
      CALL FRHCM 
      CALL ABUT 
      CALL JLIMS(0,0,1,1,1,1) 
C   PREPROCESS THE OUTLINE DATA IN DAT INTO IDAT 
C   AND SCAN IT IN 
      CALL PRSCAN(0.0,0.0,1.0,1.0,19,DAT,IDAT,12) 
C   DRAW SURROUNDING RECTANGLE 
      CALL BOXA(0.,0.,1.,1,) 
      CALL ADVFLM 
      CALL ENDSPR 
      STOP 
      END 
⇑ Top of page
© Chilton Computing and UKRI Science and Technology Facilities Council webmaster@chilton-computing.org.uk
Our thanks to UKRI Science and Technology Facilities Council for hosting this site