Contact us Heritage collections Image license terms
HOME ACL Associates Technology Literature Applications Society Software revisited
Further reading □ Contents1. Introduction2. Definition of regions3. Line drawing4. Character typing and plotting5. Control procedures7. Extended facilities10. References
ACD C&A INF CCD CISD Archives Contact us Heritage archives Image license terms

Search

   
ACLLiteratureICL 1906A manualsGROATS
ACLLiteratureICL 1906A manualsGROATS
ACL ACD C&A INF CCD CISD Archives
Further reading

Contents
1. Introduction
2. Definition of regions
3. Line drawing
4. Character typing and plotting
5. Control procedures
7. Extended facilities
10. References

Chapter 7: EXTENDED FACILITIES

In this section some of the system routines in less general use are described; also, there are descriptions of some procedures which are available in source form to be incorporated into the user's object program.

7.1 GRATICULE PRODUCTION

Unlike the standard graphical pen-plotters, the SC4020 hardcopy output uses specially treated paper. A consequence of this is that, unlike the pen-plotters which use graph paper, the SC4020 sheet is initially blank and if a graticule of any kind is required then this must be produced by the user.

A procedure in the GROATS package is available for covering the selected region by a graticule. For example:

graticule at (dx, dy);

will draw horizontal lines across the region at a separation of 'dy' and vertical lines at a separation of 'dx' in the units of the selected region. The program:

1imits (0, 0, 7.5, 7.5) ;
graticule at (0.1, 0.1);
graticule at (1, 1);

would define the whole region as having inches as units and graph paper would be produced at intervals of 0.1in. The second call of 'graticule at' would darken the markings every 10th line. The lines are drawn so that lines in both directions would pass through the point (0, 0) if that was in the bounds of the selected region. It is perhaps worth emphasizing that graticules will be produced much more efficiently in the 'use axes' rather than 'use vectors' mode. A second procedure is:

axes at (x, y);

which draws axes through the point (x, y).reaching to the edges of the selected region.

Scales may be printed in the horizontal and vertical directions by calling:

scales at (dx, dy, xo, yo, mx, nx, my, ny);

This takes (x, y) as the origin and prints the values at intervals of 'dx' and 'dy' in the two directions. In the x-direction, the printing will occur just below the line y = yo and the form of printing will be equivalent to:

typenumber (x, mx, nx) ;

For integers, the least significant digit will be positioned at the point to which the printing refers. Otherwise the decimal point will be at this position. In the y-direction, the printing will be to the left of the line x = xo and the centre of the characters will be positioned at the point to which they refer. For example:

limits (0,0, 10, 10);
region (2, 2, 8, 8, 1);
select region (1);
limits (0, 0, 5, 5);
graticule at (0.1, 0.1);
graticule at (1, 1);
scales at (1, .5, 0, 0, 1, 0, 1, 1);

would define a region in the centre of the plotting area having units ranging from 0 to 5 in both directions. The graticule is again at intervals of 0.1 with the unit positions darker. Around the edge of the region the scales are marked every integer position in the x-direction and every 0.5 in the y-direction. In the y-direction, one place before and after the decimal point is printed.

7.2 IDENTIFICATION SUBROUTINES

In the production of the identification frame, two procedures have been written for obtaining information about the job. The first is:

job title (A) ;

which stores as a string in the array A, from A[1] onwards, the title of the job. This could then be output on a frame by:

type string (addr(A, 1));

The array A must be one-dimensional and have a range from A[1] to A[9] at least.

The second procedure will read into the array A either the current time or date:

job time date (A,I);

If I = 1 the current time is put in the array A, while I = 2, will put the current date. Once more the string is stored from A[1] onwards (the range must be from A[1] to A[4] at least).

7.3 USER DEFINED CHARACTERS AND FONTS

7.3.1 To modify an existing font

The procedure 'define new character' when called will read in internal code from the currently selected input stream the definition of a GROATS character which will replace the existing definition if one exists. The new character definition added will be to the currently selected font. The format for redefining a character is given later. There is no limit to the number of characters that may be redefined. However, new definitions do not replace the old definitions but are added to the end of the definition table. This could mean that if a large number of characters are redefined then the space available to each font will be filled. Each font is allowed room for defining approximately 3500 lines in the complete character set.

If the number of characters being redefined starts getting large, it is preferable to redefine the complete font. In this case, the new font definition completely replaces the old font definition. A new font is defined by calling 'define font'. This procedure, when called, will read in internal code from the currently selected input stream the complete font definition. The format of the data for redefining a complete font is given later.

7.3.2 GROATS character fonts

The standard fonts are defined in terms of a rectangle W units wide and 2H units deep. The origin is at the top left hand corner and X increases from left to right while Y values increase as one goes from top to bottom of the rectangle. Thus the bottom right-hand corner of this rectangle is the point (W, 2H). Each character in the font is defined to be within the bounds of a rectangle of this form. The assumption is made that characters will sit on the horizontal line halfway down the rectangle. That is the line joining the points (0, H) and (W, H). For plotting, the centre of the character is assumed to be at the point (CX, CY). It is usual to have CX = W/2 and CY = H/2. The parameters W, H, CX, and CY are defined once for all characters in the font.

Character typing in GROATS will output characters with the rectangular regions for the characters touching. This means that it is usual to leave sufficient space at the sides of each character so that during typing, characters do not run together. Similarly, a newline will be typed with its rectangles touching the row above. Sufficient space should therefore be left at the bottom of the character definitions so that two lines do not run together. The maximum value allowed for W and H is 31. This is so that character definitions may be packed one or two lines per word.

The standard font size for each font is defined as W raster positions in the X direction and 2H raster positions in the Y direction. This is obtained by calling:

character factor (1) ;

The font may be output in any size by using one of the procedures for redefining the size of characters on the output.

Input Character Definition:

The input expected for defining a character using the procedure 'define new character' is as follows:

<character number><character definition>
<character number>::=<positive integer> | <negative integer> < positive integer> 
<character definition>::=<line definition *?>F | E<positive integer> 
                       S<positive integer><positive integer> 
<line definition>::=V<positive integer><positive integer><positive integer> <positive integer> |
                       T<positive integer><positive integer> 
<positive integer>::= A positive integer followed by a terminator 
                       consisting of a , or two spaces.
<negative integer>::= A negative or zero integer followed by a terminator 
                       consisting of a , or two spaces.

Examples of character definitions are as follows:

-17 1 V4, 1 , 5, 0, T5, 10 , V3, 10, 7, 10, F 
128 S 1 ,9 
140 V5, 1 , 5, 10, V3, 7, 5, 10, T7, 7, F 
161 E 33 

These are in fact four of the definitions in the standard font 0.

The <character number> defines which GROATS character is being defined. If the first possibility consisting of a single positive integer is written then this is the number of the character in the GROATS character set. If the character being defined has a hardware character representation and the user wishes to use the hardware character in place of the software character whenever the font is being output in hardware size then the second alternative is used. The negative of the GROATS character number is output followed by the SC4020 hardware character number replacing this character. Our four examples are therefore defining the GROATS characters 17, 128, 140, and 161 (ie 1, Newline, downarrow, A). The first of these, the digit 1, will be replaced by the hardware character numbered 1 when the font is being output hardware size.

The most usual method of defining the character is as a set of lines using the co-ordinates of the rectangle box defined above. The rectangle can be thought of as having a unit declaration:

limits (0, 2H, W, 0);

The definition then consists of a set of lines equivalent to GROATS calls as follows:

Vp, q, r, s defines   vector (p, q, r, s);
Tw, x       defines   topoint (w, x);

The definition is terminated by the letter F.

If the definition of a character is identical to that for another character in the font which has already been defined then the definition takes the form

p E q

where this defines the GROATS character p as being identical to character q. In the example the upper case Greek letter A is defined as being identical to the standard upper case A.

The character may be defined as a setting procedure. This is done by

p S q r

which defines GROATS character p as the setting procedure obtained by calling:

define char as special (p, q, r);

In the example the character 128 is defined as the setting procedure 'newline'.

7.3.3 Input Font Definition

A complete font definition consists of 256 character definitions for the GROATS characters 0 to 255 in any order. These are preceded by:

FONT i 
W, H, CX, CY

where i is the number of the font and W, H, CX, and CY are integers as defined above. The standard FONT 0 has, for example, a definition starting:

FONT 0
10, 10, 5, 5 
0  63 F
-1 48 F
-2 12 V4, 2, 4, 4, V6, 2, 6, 4, F

It is usual to equate undefined character positions to the space character (GROATS character 1). For example,

210 E 1

The user-defined fonts will normally work in both constant and variable width spacing modes. The procedure 'define font' will automatically produce the necessary table for variable width spacing. If later, new characters are defined for a font by calling 'define new character' then the variable width table could be incorrect. It is therefore sensible, after redefining characters, to call:

define variable widths;

before storing the font away or using it. It is called automatically by the procedure 'define font'.

7.3.4 Defining and Accessing Non-Standard Fonts

The facilities described above allow the user to redefine either individual characters or a complete font for the current run of his program. The user may, however, require a non-standard font on many runs of his program. In this case, it is preferable that these non-standard fonts are loaded initially rather than the standard fonts.

If a user has a parameter

FONT filename

in the call to the GROATS macro then the fonts used by the GROATS package {and the user program) will be loaded from the file 'filename' instead of from the standard system file.

7.4 SAVING PLOTTING ORDERS, DEFINING PICTURES

When producing cine films, it frequently occurs that some part of each frame may behave as a static background, which appears on several frames: alternatively, the user may have some pictorial object which he wishes to display on a number of frames, possibly modifying it slightly from one frame to the next. Rather than having to recompute this information, the user can store it and then re-use it as and when required.

There are two saving systems available: one is to define "pictures" - pictorial information is stored and given a name chosen by the user: this picture can then be displayed or modified merely by specifying the name the user has associated with this pictorial object. The other saving system is somewhat simpler - the plotting information is saved in an array nominated by the user, who may then re-use the saved information at the required points in his program.

7.4.1 Defining Pictures

There are two methods of defining pictures

  1. by a call to the procedure 'def'
  2. by using the procedures 'start def', 'finish def', 'fidef'.

These procedures save the plotting information in a stack created solely for this purpose. When 'def' or 'start def' is entered, a check is made to see if this stack, henceforward called the "picture stack", exists: if not, it is created automatically. The user need not attempt to set up this stack initially, and there is no mechanism provided for him to do so. The picture stack is situated in virtual memory above the normal Algol stack: the Algol stack starts at address 512K and the picture stack at address 1M. Thus the limit on the size of the Algol stack when defining pictures is 512K words.

The initial size of the picture stack is 1K words, and the picture defining routines automatically attempt to enlarge this (in increments of 1K words) by requesting an increase in the active program size. This will be granted until an attempt is made to extend the program's size beyond the maximum permitted for the user program. If an increase in size is not granted, then a diagnostic message will be printed and the program will halt: the standard error procedure will then be entered.

The maximum size of the picture stack is the maximum program size minus the amount of core used by the remainder of the program ("remainder of the program" means the program code areas plus all data areas (including the Algol stack) but excluding the picture stack).

def

The declaration of this procedure is:

procedure def(proc,st);
procedure proc;
string st;
algol;

The procedure 'def' stores away the picture that would have been generated if a call of the procedure 'proc' had taken place at this point. The procedure 'proc' must have no arguments. The string 'st' is the name assigned to this pictorial information. The name can be of any length but only the first seven are used to define the item. Different names must therefore differ within the first seven characters. For example:

def (border, 'box around region');

defines the border surrounding the current region and gIves it the name 'box around region'.

start def, finish def, fidef

This method of defining a picture is similar to 'def' except that plotting orders between calls of 'start def' and 'finish def' are stored away. Both procedures must be called with the same string argument. For example :

start def ('box around region');
border;
finish def ('box around region');

s equivalent to def (border,'box around region');

The procedure 'fidef' is used in exactly the same way as 'finish def' but it does not require an argument: it terminates the definition of the picture currently being defined (note: only one picture can be defined at once). Thus the example above could be written :

start def ('box around region');
border;
fidef;
Different forms of the information stored

Pictorial information may be stored in two different forms. The absolute positions of the lines on the display area may be stored or alternatively (X,Y) co-ordinates relative to a particular region. The second method is the more costly in space but it does allow more flexibility in the form that drawing can take. Normally, all plotting will be stored in the first or absolute form. The form of storage relative to the units set for the region is obtained by calling the procedure

absolute (false);

The switch can be reset to absolute by calling

absolute (true);

If a picture is being saved in the relative mode, then the information stored will depend on the vector drawing order used. When the saved picture is drawn, the output will, of course, depend on the type of information stored in the save area. In the following table the columns give

  1. The original drawing command
  2. The form saved
  3. The orders generated when the saved information is used.

The variable R is used to denote the currently selected region. It is assumed that this region is selected before the order in column (3) is executed. The parameters LASTX and LASTY are used to indicate the end point of the last vector drawn. For example :

vector (X1, Y1, X2, Y2);

will set

LASTX = X2, LASTY = Y2

Similarly

topoint (X, Y);

is equivalent to

vector (LASTX, LASTY, X, Y);
(1) (2) (3)
vector (X1, Y1, X2, Y2); R,X1,Y1,X2,Y2 vector(X1,Y1,X2,Y2);
setlast(X,Y); R,X,Y setlast(X,Y);
penup(X,Y); R,DX,DY penup(LASTX+DX,LASTY+DY);
topoint(X,Y); R,DX,DY topoint(LASTX+DX,LASTY+DY);
storeline parameters; R,B,D,T broken(B);dark(D);thick(T);
draw(NAME,0) R,NAME draw(NAME,-1);

The values of DX and DY stored are X-LASTX and Y-LASTY respectively. The values of LASTX and LASTY are those when the saved picture is being defined. The values of LASTX and LASTY in column (3) are the current values when the picture is being used. These can, of course, be different.

The procedures 'vector' and 'topoint' have their usual meaning.

Details of the other procedures available follow:

set last

The declaration of this procedure is:

procedure set last (X,Y);
value X,Y;
real X, Y;
algol;

This procedure resets the value of LASTX and LASTY to X and Y respectively.

penup

The declaration of this procedure is:

procedure penup(X,Y);
value X,Y;
real X, Y;
algol;

This procedure resets the value of LASTX and LASTY to X and Y respectively. It differs from 'set last' in that when used in a saved definition, it defines a relative movement of the drawing position rather than an absolute one.

store line parameters

This stores the current values of the 'broken', 'dark' and 'thick' parameters for the selected region if the procedure is used in a save definition.

draw

The declaration of this procedure is:

procedure draw (st, num);
value num;
integer num;
string st;
algol;

This procedure allows the user to display several subpictures for 'num' frames; the names of the subpictures should be put in the argument 'st' separated by commas.

For example, if subpictures named BORDER, CIRCLE, ELLIPSE have been defined then:

draw('BORDER', 10);
draw('BORDER, CIRCLE', 15);
draw('BORDER, CIRCLE, ELLIPSE', 10);

would produce a film sequence of 10 frames with just BORDER displayed followed by 15 frames with BORDER and CIRCLE displayed and then 10 frames with BORDER, CIRCLE and ELLIPSE displayed.

If the value of 'num' is negative then the result is to draw the picture -num times with no advance films in between. Usually only num = -1 is required.

If the value of num = 0 then there will be no action unless the call of 'draw' is part of the definition of a picture in relative mode. In this case the string 'st' is stored In the save area and using this item will be equivalent to

draw (st, -1 ) ;

Note the important difference between the following definitions:

absolute (false); 
startdef ('AA');
draw ('FRED', -1);
finishdef ('AA'); 
startdef ('BB');
draw ('FRED' ,0);
finishdef ('BB');

In the first case the definition of AA will contain all the line drawing orders making up the definition of FRED. In the second case, the definition of BB will just contain the name of FRED. This is obviously a saving in space. In addition if FRED is redefined then this will have no effect on AA's definition but EE will now be equivalent to the new version of FRED.

draw from to

The declaration of this procedure is:

procedure draw from to(st1, st2, FR);
value FR;
integer FR;
string st1, st2;
algol;

This procedure changes the picture defined as 'st1' into the picture defined as 'st2' in FR + I frames if FR > 0. If FR < 0 then the intermediate positions are all displayed on the same frame. If the strings 'st1' and 'st2' consist of several items then they must both be the same length. Each item is transformed into its equivalent item.

Two restrictions on the use of this procedure are

  1. Two items in equivalent positions in the strings must have all plotting defined in the same region.
  2. All plotting in both st1 and st2 must be in the relative form and using only vector or topoint commands. The other relative forms are not allowed.

For example:

absolute (false);
def (circle, 'CIRCLE');
def (border, 'BORDER'); 
def (square, 'SQUARE');
def (ellipse, 'ELLIPSE');
draw from to ('ELLIPSE, SQUARE','CIRCLE, BORDER', 10);

would change ELLIPSE into CIRCLE and SQUARE into BORDER in the next 11 frames.

The movement from one object to another is achieved by taking the position of equivalent lines in the two objects and linearly interpolating to give the position for each frame. If one picture has more lines than another then the picture with fewer lines will have lines broken into two until the two items are of equal length. This procedure is particularly useful for producing animated movement.

drawvar

The declaration of this procedure is:

procedure drawvar (st, num, proc);
value num;
integer num;
string st ;
procedure proc;
algol;

Frequently a constant background is required together with some information whose position varies linearly over a set of frames. The procedure 'drawvar' will generate 'num + 1' frames consisting of the background 'st' defined as for 'draw' with, in addition, a variable picture defined by calling 'proc'. The global variable 'framemax' is set to 'num' and the global variable 'fram' takes the value 0, 1, 2 ... num in calls of 'proc'. The procedure 'proc' can therefore define the variable plotting required depending on 'fram'. For example:

procedure movingbox;
begin real r, a;
r:-= 1/framemax;
a:= r * (5 * (framemax - fram) + 7 * fram);
box (a, a, a + 3, a + 3);
end;
drawvar ('BORDER, CIRCLE', 20, movingbox);

would produce 21 frames with the background BORDER and CIRCLE and a box which starts having co-ordinates (5, 5, 8, 8) and finishes with co-ordinates (7, 7, 10, 10).

change display

The declaration of this procedure is:

procedure change display (stl, st2, N);
value N;
integer N;
string st1,st2;
algol;

This procedure is used to dissolve the picture st1 into the picture st2 in N + 1 frames. At each frame, 1/N lines of the display st1 are replaced by 1/N lines of st2. The pictures defined as st1 and st2 must consist only of lines and, in particular, must not contain any hardware character plotting. Also, it is advisable that the frame count and cutmark are not being produced. For example:

change display ('BORDER, CIRCLE', 'ELLIPSE', 10);

will dissolve the BORDER and CIRCLE into ELLIPSE in 11 frames.

remove, removei, release

These three procedures provide different methods of reclaiming space in the picture stack. For example:

remove ('FRED');

would remove the picture called FRED from the stack and make this storage space available again. The procedure 'removei' is similar. For example:

removei ('ALF,FRED,SID' ,2);

would remove the second item in the string. That is the picture FRED would be removed. This is sometimes a useful alternative when passing multiple named strings between routines.

The procedure 'release' removes not only the picture defined in the string name but also all pictures defined after the definition of this picture. Care should be taken when using this procedure as the procedure 'draw from to' may redefine existing pictures unknown to the user.

Accessing the Picture Stack

Although the picture stack is not an Algol array, it is possible to access it as such by means of the following:

  1. declare a one dimensional real array:
    real array ARRY[1:2];
    
    (the name of the array is not significant - the user can choose his own).
  2. make the procedure call
    save array (ARRY);
    

The action of this procedure is to generate an Algol array header for the picture stack, and to overwrite the header of the specified array with the header just generated. Thereafter, references to the array ARRY, for example:

ARRY [I] :=3.0;
print(ARRY[4],20,0);

will refer to the corresponding element of the picture stack. The original contents of the array ARRY are irretrievably lost, and hence there is no point in initially declaring ARRY to be an array with a large number of elements.

After making a call to 'savearray', the user may define further pictures: this could possibly cause the picture stack to be extended. A 1900 Algol array header contains, amongst other information, the address of the first word after the end of the array; if the picture stack has been extended, this address will be the address of the first word added to the stack, and the Algol array header will now only refer to that portion of the new picture stack that formed the entire picture stack when the call to 'savearray' was made. Hence, after defining further pictures, the user should make another call

savearray (ARRY);

if he wishes to reaccess the picture stack (this point is particularly important if the user wishes to access the new portion of the picture stack).

It is possible to determine which elements of the picture stack are occupied by a specified picture. For example, the programmer wishes to access the save area of the picture FRED: the following program demonstrates, this:

real array A[1:2];
integer I,J,K;
...
savearray(A);
I := hash ('FRED',1);
J := savepointer(I*2);
K := savepointer(I*2+1);

After this, the picture FRED can be accessed as the array elements A[J], A[J+l], ...... ,A[K-l].

7.4.2 Saving Plotting Orders

This section describes the alternative method of storing plotting information: we start with an example.

It is possible that some part of a frame may behave as a static background which is required to appear on several frames. Rather than having to recompute this information, it is possible to save the orders in an array. For example:

background; 
scene (1) ; 
background ; 
scene (2) ; 
background ; 
scene (3) ;

might define a program which produced 3 frames called scenes 1 to 3 with a static background. This could have been written:

start saving (A, 1, 1000);
background ;
finish saving (A, MAX);
scene (1) ;
use saved (A, I, MAX);
scene (2) ;
use saved (A, I, MAX);
scene (3) ;

The one dimensional real array A is provided by the user to store the SC4020 orders. The procedure 'start saving' defines the limits of the area of the array to be used - in the example, the SC4020 orders will be stored from A[1] onwards, using as many elements of the array as are required, up to (and including) A[1000]. If an attempt is made to store plotter orders beyond the end of the specified array area (ie if an attempt is made to store more plotter orders than will fit into the specified area) then the saving of plotting information is terminated, and a diagnostic is printed.

The procedure 'finish saving' terminates the saving of plotter orders, and returns in MAX the first free location of the array A not used by the SC4020 orders. The procedure 'use saved' causes the SC4020 orders to be re-output at this point. In the example, the SC4020 orders are saved in the array elements A[1] to A[MAX-1]. Four more array elements are required than the number of SC4020 orders saved.

It frequently happens that the amount of information that is to be saved gradually increases. On one frame a certain amount of graphical output is presented; on a subsequent frame this together with some additional output is to be displayed and so on. The procedure 'use saved and restart' is intended for such situations: the following program indicates how it could be used:

start saving (A,1,10000);
scene;
finish saving (A,J);
advance film;
for i:= 0 step 1 until 10 do 
begin 
  use saved and restart (A,1,J,10000);
  output addition to scene(i);
  finish saving (A,J);
  advance film;
end;

The declaration of the procedure 'use saved and restart' is

procedure use saved and restart(A, IST, J, IMX);
value IST,IMX,J;
integer IST,IMX,J;
array A;

A call to this procedure will cause the equivalent action of:

use saved(A, IST, J);

and will then continue storing information in element A[J] onwards, up to element A[IMX]: the error action if an attempt is made to store information beyond A[IMX] is the same as in 'start saving'. After a call to 'use saved and restart', saving is continued until the next call to 'finish saving'.

The user should note that the call:

use saved and restart (A, IST, J, IMX);

is not equivalent to the two calls:

use saved (A,IST,J);
start saving(A,J,IMX);

since 'start saving' causes a four element header block to be put in the elements A[J], , A[J+3], whereas 'use saved and restart' causes the header in elements A[IST], . A[IST+3] to be updated. Thus the program

start saving (B,1,1000);
....
finish saving (B,MAX);

creates a save area in array elements B[1], B[2], ..... , B[MAX-1].

If this program is followed by

use saved and restart (B,1,MAX,1000);
....
finish saving (B,MAXI);

then the save area will now be B[1], B[2], .... , B[MAXI-1] with only one header in B[1], B[2], B[3] and B[4]. If however, the second of these programs was

use saved (B,1,MAX);
start saving (B,MAX,1000);
...
finish saving (B,MAXI);

then there would be two save areas B[1], B[2], ..... , B[MAX-1] and B[MAXI], ........., B[MAXI-1] with headers in B[1] to B[4] and B[MAX] to B[MAX+3]. In this case, the call

use saved (B,1,MAXI);

will probably cause an execution error when an attempt is made (by 'use saved') to plot the header in B[MAX] to B[MAX+3].

The plotting information can be saved in both relative and absolute modes, as for picture definition: the routines

vector 
setlast 
penup 
topoint 
storeline parameters

are available - their use and properties are as described in section 7.4.1. However, it is not possible to save a call to procedure 'draw': the calls

draw ('NAME', 1) ;
draw ('NAME' ,-1);

both result in saving either the calls to the procedures called in defining the picture NAME (in relative mode) or the SC4020 orders (in absolute mode). The call

draw ('NAME' , 0) ;

will have no effect. If the call:

draw('NAME' ,3);

is made while saving in relative mode, then the advancefilm orders will not be saved (but will be if the saving is in absolute mode).

7.4.3 Saving while defining pictures etc

Calls to 'start saving' while defining a picture, or calls to 'start def' (or 'def') while saving are not allowed: these conditions are detected, diagnostics are printed, and the offending procedure call is ignored. For example the two programs

start def ('SHAPE1');
vector(1,1,2,2);
start saving(A,1,1000);
vector(2,4,5,6);
fidef;
border;
finish saving(A,MAX);
and
start def('SHAPE1');
vector(1,1,2,2);
start saving(B,1,500);
vector(2,4,5,6);
finish saving(B,MAX);
fidef;
border;

are both equivalent to:

start def ('SHAPE1');
vector(l,1,2,2);
vector(2,4,5,6);
fidef;
border;

Similarly, calls to 'start def' while already defining a picture, or calls to 'start saving' while already saving, are ignored. Thus the program

start saving(A,1,1000);
vector(0,0,1,1);
start saving(B,1,500);
border;
finish saving (A,MAX);
vector (0,1,0,2);
finish saving(B,MAXB);
vector(3,2,1,4);

is equivalent to

start saving (A, 1, 1000);
vector (0,0, 1, 1);
border;
finish saving (A,MAX);
vector (0,1,0,2);
vector (3,2,1,4);

Note however that the program

start saving (A, 1, 1000);
vector (0,0,1,1);
start saving (B,1,500);
border;
finish saving (B,MAXB);
vector (0,1,0,2);
finish saving (A,MAX);
vector (3,2,1,4);

will produce indeterminate results. The second call to 'start saving' will be ignored (and produce a diagnostic), and after this call, saving will continue in array A. The first call to 'finish saving' will be executed, but with one unfortunate feature, namely that it will assume (from the array parameter) that plotting information is being saved in B, whereas it is actually being saved in A: this may cause the program to fail.

The programs

start def ('PICA'); 
vector (0,0, 1, 1); 
start def ('PICB');
border;
finish def ('PICA');
vector (4,5,6,7);
finish def ('PICB');
vector (1,2,3,4);

and

start def ('PICA');
vector (0,0,1,1);
start def ('PICB');
border;
fidef;
vector (4,5,6,7);
fidef;
vector (1,2,3,4);

are both equivalent to

start def ('PICA'); 
vector (0,0, 1, 1);
border;
fidef;
vector (4,5,6,7);
vector (1,2,3,4);

However, the program

start def ('PICA');
vector (0,0,1,1);
start def ('PICB');
border;
finish def ('PICB');
vector (4,5,6,7);
finish def ('PICA');
vector (1,2,3,4);

will produce indeterminate results, since the second call to 'start def' will be ignored, and so when the call

finish def ('PICB');

is executed, the picture being defined is PICA, not PICB.

7.5 THE PROCEDURE FRACTION

procedure fraction (I, MAX,RST,RFI,TYPE);
value I, MAX, TYPE;
integer I, MAX, TYPE;
real RST, RFI;

If an object is to be moved from one position to another over MAX + 1 frames then it is necessary to know its position at the Ith frame where I = 0 (1) MAX.

The procedure 'fraction' when called with I and MAX set, will return in RST the fraction of the distance between the starting and final positions that still has to be moved after I frames. The parameter RFI is set to 1-RST.

For example, if a coordinate of the object moves from (XST, YST) to (XFI, YFI) then its position after I frames will be: (XST*RST + XFI*RFI, YST*RST + YFI*RFI). The parameter TYPE is used to define different types of motion

In TYPE = 2,3 the final and initial increments are approximately 0.5π/MAX. This is useful to know if the speed is intended to continue at a constant velocity. When using the procedure 'drawvar', the global parameter FRAM and FRAMEMAX should replace I and MAX in the call of 'fraction'.

7.6 GRAPHIC LIBRARY

It is hoped that the GROATS package defines a fundamental graphic system which can be extended by library routines to cover most user applications. There are a number of library procedures available, as detailed below: additional procedures will be documented as they become available.

Files GR1A, GR1D, GR1P, GR1PA contain source listings of the GROATS system, and are provided for user's reference. The other files contain Algol procedures, held in source form, and may be incorporated into user's programs. They are listed in the order of the filenames, not alphabetical order of procedure name.

7.6.1 GR1A, GR1D, GR1P, GR1PA

These contain source listings of different parts of the GROATS system:

GR1A
Algol source
GR1D
List of GROATS declarations
GR1P
PLAN source
GR1PA
Source (in PLAN) of modified version of the ICL procedure % ASELECT0.

7.6.2 GR2

procedure texture(xmn,ymn,xmx,ymx,type,deg);
value xmn,ymn,xmx,ymx,type,deg;
integer type,deg;
real xmn,ymn,xmx,ymx;

The rectangular area in the selected region having opposite corners (xmn,ymn) and (xmx,ymx) will be 'textured' by one of several possible patterns.

The periodicity of the pattern varies according to the setting of the parameter 'deg'. If deg = 0 then the periodicity is 20 raster positions, deg = 1 then 10 raster positions, deg= 2 then 5 and so on. On the hardcopy output, 20 raster positions is about .15 inches.

There are 9 different designs available in the procedure and the one used is determined by the parameter 'type'. These are as follows:

type design
0 No design at all.
1 Plotting dots aligned by rows.
2 Horizontal lines.
3 Vertical lines.
4 Diagonal lines (bottom left to upper right).
5 Diagonal lines (top left to bottom right).
6 Horizontal and vertical lines.
7 Diamonds formed from the two sets of diagonal lines.
8 The equivalent of 1 together with itself displaced by .5 of period in each direction.

The periodicity of the pattern is, in fact, 10*21-deg. Values of 'deg' outside the range 0 to 2 will probably have little value as they produce texture either too course or too fine.

7.6.3 GR3

procedure histogram (X,Y,DX,YV,M,N,TYPE,DEG);
value X,Y,DX,M,N;
integer M,N;
real X,Y,DX;
integer array TYPE,DEG;
real array YV;

The procedure draws axes across the selected region through the point (X,Y). In addition a histogram will be drawn. The interval in the x-direction will be DX. The histogram drawn will have y-values, YV[i] in the interval (X + (i - M) * DX, X + (i - M + I) * DX). The histogram is defined for x-range, (X,X + (N - M + 1) * DX). That is, the function values defined are YV[M] to YV[N]. The Ith interval will be shaded with texture of type TYPE[I]and degree DEG[I]as defined in GR2.

The elements of the histogram may extend either above or below the base line y = Y.

The library item GR2 must also be added to the program when GR3 is used.

7.6.4 GR4

procedure conic (X,Y,A,B);
value X,Y,A,B;
real X,Y,A,B;

The procedure will draw the conic:

(x-X)2/A2 + (y-Y)2/B2 = 1 if A>0, B>0

(x-X)2/A2 - (y-Y)2/B2 = 1 if A>0, B<0

(y-Y)2 = 4A(x-X) if B=0

The units are those of the selected region. For B>0, the curve is cut off as the bounds of the selected region. The procedure uses library item GR5.

7.6.5 GR5

procedure curvfunc (F, XMN, XMX)
value XMN, XMX;
real XMN, XMX;
real procedure F;

This procedure draws the curve y = F(x) between XMN and XMX. The function F(x) must be single values between XMN and XMX (XMN < XMX).

7.6.6 GR6

procedure curve (C,N,XV,YV);
value C,N;
integer C,N;
real array XV, YV;

The set of points XV[I] , YV[I] for I = O(1)N are joined to form a closed curve if C = 0 and an open curve if C = 1. The points I and I + 1 are joined by the arc of the circle which also goes through the point I + 2. Points can be repeated but no two consecutive points can be identical. (In the case of closed curve, points N and 0 are treated as consecutive). The curve produced will appear smooth if sufficient points are used.

7.6.7 GR7

procedure composite histogram (X,Y,DX,YV,M,N,NV,TYPE,DEG);
value X,Y,DX,M,N;
integer M,N;
real X,Y,DX;
integer array TYPE,DEG,NV;
real array YV;

This procedure is similar to GR3. The procedure draws axes across the selected region through the point (X,Y). In addition a histogram will be drawn. The interval in the X-direction will be DX and the histogram is defined for intervals (X + I*DX, X + (I + l)*DX) where I ranges from M to N.

For each interval I, instead of a single Y value to be plotted, NV[I] different Y values may be given and each sub-part of the histogram may be textured differently. For each interval I, a set of Y-values, YV[I,J] must be given for J = 0 to NV[I] and YV[I,J] > YV[I,J - 1] and YV[I,J] will be shaded with texture TYPE[I,J] and degree DEG[I,J]. (see GR3, section 7.6.3).

The procedure uses the procedure 'texture' defined as GR2.

7.6.8 GR8

procedure shade area (XV,YV,N,XMN,YMN,XMX,YMX,TYPE,DEG);
value N,TYPE,DEG,XMN,YMN,XMX,YMX;
integer N,TYPE,DEG;
real XMN,YMN,XMX,YMX;
real array XV,YV;

A closed area is defined by the set of points (XV[I], YV[I]) where I = 0(1)N. The point (XV[0], YV[0]} is joined to the point (XV[N], YV[N]). The consecutive points are assumed to be joined by straight lines. The area so defined is textured by a pattern defined by TYPE,DEG. These parameters have the same meaning as in the library item 'texture' defined as GR2.

An even number of vectors that are coincident has the same effect as no vectors so that it is possible to shade figures with holes in or alternatively two distinct figures with the same texture simply by joining the figures with a pair of coincident vectors from any two points. For example a square defined by the points 1, 2, 3, 4 having a triangular hole defined by 5, 6, 7 can be shaded by defining the area to be shaded as 123456754. The procedure only produces the shading. It does not join the edge points of the area by straight lines. The arguments XMN, YMN, MXM, YMX define the limits of the currently selected region.

7.6.9 GR9

procedure illustrate (N,XV,YV,XMN,YMN,XMX,YMX,NAREAS, 
    TYPE,DEG,NVEC,NV,NLINES,NPOINTS,NP);
value N,NAREAS ,NLINES ,XMN,YMN, XMX, YMX;
integer N,NAREAS,NLINES;
real XMN, YMN, XMX, YMX;
real array XV,YV;
integer array TYP,DEG,NVEC,NV,NPOINTS,NP;

This is an extension to GR8 which will allow a whole scene or picture to be produced which consists of several areas to be shaded and several lines to be drawn.

The arrays XV,YV[I : N] contain the coordinates of all the points defining the areas and lines.

The number of areas is defined by NAREAS. The Ith area has texture defined by TYP[I], DEG[I] and is defined by the sequence of points XV,YV[K] where K = NV[I,J] and J = 0(1) NVEC [I]. In addition NLINES lines will be drawn. The Ith line (I = 1(1)N) is drawn between the points (XV,YV[K]) where K = NPOINTS[J] and J = 1(1) NPOINTS[I].

This indirect way of addressing the points which define the object does mean that texturing of a scene with certain characteristics but changing in detail can be achieved by simply changing the set of data values in XV,YV.

The shading is done by using procedure 'shade area' in library file GR8, which must also be included in the program. The values XMN, YMN,XMX,YMX are the limits of the selected region.

7.6.10 GR10

procedure contour (XV,M,YV,N,ZV,CV,R);
value M,N,R;
integer M,N,R;
real array XV,YV,ZV,CV;

A mesh is defined by the set of X and Y values, XV[O : M] and YV[0 : N]. At the intersections on the mesh, a function is defined having values ZV[O : M][O : N]. This procedure will attempt to draw the set of contour lines at the function values CV[I : R]. The mesh must be sufficiently fine so that a contour line must not enter and leave a square on the same side.

The contour lines are drawn by using the procedure 'curve' defined as GR6. This joins points together on grid lines which have function values equal to the contour value. These points are found by linear interpolation over each of the grid squares in turn.

The procedure does not draw axes, graticule or scaling. These must be produced by the user.

7.6.11 GR11

procedure curve (F,P,A,B,INC,PHI,EPS);
value A,B,INC,PHI,EPS;
real A,B,INC,PHI,EPS;
procedure F;
real array P;

This procedure draws the function F in the range A ≤ T ≤ B where T is a parameter from which both the x and y co-ordinates are found by F. P is an array of constants which may be used in the definition of F. The maximum increment of T is INC and this is subdivided recursively until chords in adjacent subdivisions differ in direction by less than PHI radians or the chords are shorter than EPS. The maximum chord length satisfying these conditions is found at all points and drawn. Finite discontinuities of the function and its derivatives will be plotted correctly. F has arguments F(X,Y,T,P).

The procedure was provided by P J le Riche.

7.6.12 GR12

procedure fan(x1,y1,x2,y2,x3,y3,x4,y4, density);
value x1,y1,x2,y2,x3,y3,x4,y4, density;
real  x1,y1,x2,y2,x3,y3,x4,y4;
integer density;

This procedure will draw a set of lines, 'density' in number, between the two lines (x1,y1) to (x4,y4) and (x2,y2) to (x3,y3). If we consider these two lines as divided into 'density + 1' intervals then the corresponding interior points on each line are joined together to form the set of lines making up the fan.

This set of lines can also be thought of as a set which interpolate between the lines (x1,y1) to (x2,y2) and (x4,y4) to (x3,y3).

7.6.13 GR13

procedure wipe (ST1, ST2, FRAMES, FRAMES, TYPE, REGION};
value FRAMES, TYPE, REGION;
integer ST1, ST2;
integer FRAMES, TYPE, REGION;

This procedure allows the user to change the picture being displayed from ST1 to ST2 in FRAMES + 1 frames. The type of wipe obtained depends on the parameter TYPE. REGION must be set to the number of a region not currently being used.

If TYPE = 1, the new picture will start appearing at the middle and will gradually grow in size until it completely covers the region.

If TYPE = 2, the new picture will start appearing at the outside and will gradually grow in size working towards the middle.

If TYPE = 3, the wipe is from left to right. The new picture appears on the left and gradually moves across the whole plotting area.

It is likely that additional wipes will be added to this routine from time to time. Pictures used in wipe must be relative.

Some Examples

(1) If a single region is to be used for a variety of dark, thick and broken lines, it is sensible to define a standard setting for yourself and define all objects which differ from this standard as separate pictures. For example:

absolute (false);
dark (2);
thick (1); 
broken (0);
startdef ('AA' );
vector (0,0,1,1); 
finishdef ('AA'); 
startdef ('BB');
broken (10);
storelineparameters;
vec tor (1, 1 ,2, 2) ;
broken (0);
storelineparameters;
finishdef ('BB');
startdef ('DD');
dark (5);
storelineparameters;
vector (2,2,3,3);
dark (2);
storelineparameters;
finishdef ('DD');
draw ('AA,BB,DD' ,1);

In this case each item drawn will leave the dark, thick and broken parameter settings in the standard form chosen. This will avoid one item having an effect on the definition of another.

(2) The definition of relative pictures can be useful at times. For example:

absolute (false);
setlast (0,0);
startdef ('BIGX');
penup (-1, -1);
topoint (1, -1);
penup (-1, 1);
topoint (1, -1);
penup (0,0);
finishdef ('BIGX');

defines an X which will be drawn centred on the last (X,Y) position drawn. It will leave the setting of the last (X,Y) position the same. Notice that the definition

absolute (false);
setlast (2,2);
startdef ('BIGX');
penup (1,1); 
topoint (3,3) ;
penup (1,3);
topoint (3, 1) ;
penup (2,2);
finishdef ('BIGX');

is identical to the one above. The origin defined outside the picture definition can be any value. The only difference is that on leaving the definition, the last (X,Y) position is (0,0) in one case and (2,2) in the other.

The set of orders:

vector (0,0, 1, 1); 
draw ('BIGX', -1);
topoint (2,2);
draw ('BIGX', -1);
topoint (3,3);
draw ('BIGX', -1);

will produce a diagonal line with an X situated at the end point of each sub-line making up the complete line form (0,0) to (3,3).

7.6.14 GR14

procedure printchar (FONTNU,I,USEFONT);
value FONTNU,I,USEFONT;
integer FONTNU,I,USEFONT;

Assuming that W = width of character, H = height of character defined in font (FONTNU) this procedure will

  1. produce a graticule on the right hand side of 1 frame of SC4020 output which is W units wide and 2H units high.
  2. plot the character, groats number I, of font FONTNU on the top half of this graticule.
  3. plot the character, groats number I, on the left hand side of the frame in three different sizes of character factor (1), (2), (3).
  4. the frame will have headings of the type
    FONT 1 
    CHARACTER 20
    
    which will be typed 1n characters from font USEFONT : usually FONTNU is not USEFONT
procedure printfont (FONTNU, USEFONT);
value FONTNU, USEFONT;
integerFONTNU, USEFONT;

The procedure will print out the complete font FONTNU where each frame of output has the same layout as that described for the procedure printchar. The headings of each frame will use font USEFONT.

7.6.15 GR15

procedure revcounter(A,M,N,R);
value A,M,N,R;
real A;
integer M,N,R;

This procedure will print the value of A, with M digits to the left of the decimal point and N digits to the right, in the region R. The size of the characters is such that they just fill the region R. If N = 0 then the decimal point is not printed. M may not be zero: if it is, a diagnostic is printed and M will be set to 1.

The method of printing A is similar to that on a counter. To output A on successive frames with the value of A increasing or decreasing will give the impression that the least significant digit is rotating. When it reaches 9 in counting forward, it causes the next digit to move around and so on.

⇑ 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