Skip to content

Drawing Tracks

Julie Montoya edited this page Mar 17, 2020 · 1 revision

The graphics library only needs to draw tracks on the screen; on the photoplotter can be instructed to draw them directly. Tracks are rendered as two parallel strokes in outline mode, or as rectangles (formed from a pair of triangles, making use of PLOT 85) in solid mode.

Lines are drawn from the co-ordinates given in lmX, lmY to the co-ordinates given in scrX, scrY.

In order to work out which extreme points to use as the limits, we need to know the direction of the line. This is done in LM_selcase using the test equality and compare functions in the maths library. There are nine possibilities; but one is a degenerate case equivalent to any of four others, so we reduce this to one of eight possible cases.

For each line, we need to plot four points in total; and each point can be in one of eight positions, corresponding to the corners of a square centred on the beginning and ending points of the line.

  • For a diagonal line from bottom left to top right, our extreme points are above and to the left of the start, above and to the left of the end, below and to the right of the start and below and to the right of the end.
  • For a vertical line from bottom to top, our extreme points are below and to the left of the start, above and to the left of the end, below and to the right of the start and above and to the right of the end.
  • All other cases are rotations of one or other of the above.

For each direction, the procedure is the same for an outline track segment:

  1. MOVE (PLOT 4) to the first extreme point, offset to the left (from the point of view of someone standing at the starting point of the line and facing towards the ending point; not necessarily towards the left-hand side of the screen) of the start of the line.
  2. DRAW (PLOT 5) to the second extreme point, offset to the left of the end of the line. This will create a line parallel to and offset to the left of the line joining the ends of the track segment.
  3. MOVE to the third extreme point, offset to the right of the start of the line.
  4. DRAW to the fourth extreme point, offset to the right of the end of the line. This will create a line parallel to and offset to the right of the centre line.

And a similar procedure applies for a solid track segment:

  1. MOVE to the first extreme point.
  2. MOVE to the second extreme point.
  3. Draw a triangle with PLOT 85 to the third extreme point.
  4. PLOT 85 to the final extreme point.

Note that the offsets from the start and end points to the extreme points are the same for each step of each procedure. In fact a fiendish bit packing scheme is used, with an 8-bit byte for each direction:

Y1 X1 Y2 X2 Y3 X3 Y4 X4
0 = below 0 = left 0 = below 0 = left 0 = below 0 = left 0 = below 0 = left
1 = above 1 = right 1 = above 1 = right 1 = above 1 = right 1 = above 1 = right

and a further 4 bytes for each step:

BYTE OUTLINE SOLID
0 4 4
1 128+5 128+4
2 4 85
3 128+5 128+85