|
The core of the drawing is the window in which the bars are drawn.
If you look at lines 10030 and 10380 you will see how the dimensions of the windows are set.
The first four items in line 10380 provide the lower left and upper right co-ordinates of the window.
The next two items in line 10380 specify the number of columns and the value of the largest column.
The largest column will always extend to 75% of the height of the window (change 0.75 in line 10040, if you do not like this), and the other columns will automatically be scaled accordingly (by col.hgt).
Lines 10070-10120 draw a scale on the y axis that is related to the value of the largest column (nxt.stp).
Six proportional gradations are always drawn, the fifth of which is equal to the value of the largest column
The next three items in line 10380 provide the values of the character heights for the x axis text, the y axis text and the main title.
The last two items are the main title, and the title of the y axis.
Much of the complexity of the program is due to the fact that the titles and scales are drawn around the window.
It is therefore necessary to keep track of the space that is used to draw text.
This is not difficult to do because you can ask GSX to tell you how much space (width or height) is taken up by the characters of a particular character height setting.
For example, in line 10190 hgt% is set to the height of the main title text and a call is made to GOSUB 8800.
This call provides the value of the width of each character (ch.wth), which when divided by x.scale# is used in line 10200 to calculate the space taken up by the title.
This information is then used to print the title in the centre of the large box at a position of gap3 above the top of the window.
Similarly, ych.wth/x.scale# is used to centre the title of the y axis along the left side of the window (line 10160).
The same technique is used to centre each x axis label on its bar (line 10260).
If you now change the first nine values of line 10380 to DATA 15,15,35,25,12,8000,1,1,1 you will find that a perfectly scaled mini-graph has been produced from the same data.
In future, the effort required to produce this type of graph is minimal.
You just change the relevant DATA lines!
Listing 5 introduces one other technique.
Lines 8400-8710 of UTILITY.GSX alter the colour of fill, text, lines, and line markers.
Setting colour% to 0 has the effect of writing in "white" and, for example, enables you to place "white" text on a black background, or to create a "white" shape within a filled shape.
There are a number of points to note.
First, when using the fill colour option, you have to specify the same fill setting that was used in the first place (line 10020).
Second, the line effect is difficult to see as the tine is so narrow.
Third, text, line markers and lines written when colour% is set to will not appear on the screen.
Finally, do not forget to set colour% back to 1 and call the relevant GOSUB when you finish!
|
|
9512 owners beware
|
| The GSX driver as shipped with the 9512 is a slightly improved version of the one 8000 machines have.
With one exception, it performs the same.
When using the draw rectangular box function with no fill, the 9512 driver erases everything written to the screen earlier on which falls within the boundaries of the box.
In contrast, the 8256/8512 driver leaves the screen intact.
This point is illustrated by line 10352 in BARCHART.GSX, listing 4.
If the line is not changed and the 9512 driver is used, the rest of the picture will | disappear.
This problem can be overcome by using the following lines:
10352 x1=llxout.box : y1=llout.box :
x2=x1 : y2=uryout.box : gosub 4000
10353 x1=x1 : y1=y2 : *2=xx2+2 : y2=y2
: gosub 4000 : x1=x2 : y1=y2 : x2=x2 :
y2=llyout.box : gosub 4000
10354 x1=x2 : y1=y2 : x2=llxout.box :
y2=llyout.box : gosub 4000 : return
The line function is being used to draw the sides of the box.
The variables 'llxout' and 'llyout' begin with letter is not number 1s.
|
|
|