As extract from the program that I posted, I post here a sequence of subroutine that I think it can be usefull in order to draw axes.
N1!, N2!: they are examples of maximum values in abscissa and ordinate.
N3!, N4!: example of pair of values to put in the graph.
The program has these features:
- the origin of the axes is 40 pixels in X and Y direction from the lower left corner, these distances are named dx! and dy!.
- the axes are drawn in this way, speaking for example about Y axe: it starts at dy! distance from the loer border, it goes at dy! distance beyond N2! and it is spaced by dy! from the upper border. to do it the process is iterative.
Generally, the subroutine ScalaOrigine is CALLed by DisegnaAssi, but in more rare cases ScalaOrigine may be CALLed alone and
scala~% = 0 AND origine~% = 1.
It may happen when we have to work on images already created and scaled and it is necessary only to restore the origin of the axes.
N1! = 113.4
N2! = 34.44
N3! = 43
N4! = 22.2
CALL DisegnaAssi
("X", "Y", N1!
, N2!
, schermo&
, YE&
, W&
, B&
, G&
) CALL DisegnaValore
(N1!
, N2!
, R&
, YE&
, G&
) CALL DisegnaValore
(N3!
, N4!
, R&
, YE&
, G&
)
'--------------------------------------------------------------------------------------------------------------------------------------------------
SUB ScalaOrigine
(scala~%
, origine~%
, X!
, Y!
, immagine&
)
fattoreX! = 1
fattoreY! = 1
IF Y!
* fattoreY!
>= dy!
+ Y!
+ dy!
+ dy!
THEN IF X!
* fattoreX!
>= dx!
+ X!
+ dx!
+ dx!
THEN fattoreX! = fattoreX! + 0.01
fattoreY! = fattoreY! + 0.01
'--------------------------------------------------------------------------------------------------------------------------------------------------
scala:
WINDOW (0, 0)-(X!
* fattoreX!
, Y!
* fattoreY!
) '--------------------------------------------------------------------------------------------------------------------------------------------------
origine:
dx% = 39
'--------------------------------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------------------------------
SUB DisegnaAssi
(X$
, Y$
, X!
, Y!
, immagine&
, ColoreCartiglio&
, ColoreAssi&
, ColoreTacca&
, ColoreNumeri&
)
taccaX! = X! \ 6
taccaX! = 0.25
taccaX! = 0.5
taccaY! = Y! \ 6
taccaY! = 0.25
taccaY! = 0.5
CALL ScalaOrigine
(1, 1, X!
, Y!
, immagine&
) LINE (dx!
, dy!
+ Y!
+ dy!
)-(dx!
, dy!
), ColoreAssi&:
LINE -(dx!
+ X!
+ dx!
, dy!
), ColoreAssi&
PSET (dx!
, dy!
+ Y!
+ dy!
), ColoreAssi&:
DRAW "F20":
PSET (dx!
, dy!
+ Y!
+ dy!
), ColoreAssi&:
DRAW "G20" PSET (dx!
+ X!
+ dx!
, dy!
), ColoreAssi&:
DRAW "G20":
PSET (dx!
+ X!
+ dx!
, dy!
), ColoreAssi&:
DRAW "H20" i% = 1
LINE (dx!
+ i%
* taccaX!
, PMAP(dy%
+ 5, 3))-(dx!
+ i%
* taccaX!
, PMAP(dy%
- 5, 3)), ColoreTacca&
x%
= PMAP(dx!
+ i%
* taccaX!
, 0) i% = i% + 1
i% = 1
LINE (PMAP(dx%
- 5, 2), dy!
+ i%
* taccaY!
)-(PMAP(dx%
+ 5, 2), dy!
+ i%
* taccaY!
), ColoreTacca&
y%
= PMAP(dy!
+ i%
* taccaY!
, 1) i% = i% + 1
'--------------------------------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------------------------------
SUB DisegnaValore
(X!
, Y!
, ColoreLinea&
, ColorePunto&
, ColoreTesto&
)
CIRCLE (dx!
+ X!
, dy!
+ Y!
), PMAP(3, 2), ColorePunto&
PAINT (dx!
+ X!
+ PMAP(0.5, 2), dy!
+ Y!
+ PMAP(0.5, 2)), ColorePunto&
LINE (dx!
, dy!
+ Y!
)-(dx!
+ X!
, dy!
+ Y!
), ColoreLinea&
, , 65520 LINE -(dx!
+ X!
, dy!
), ColoreLinea&
, , 65520 '--------------------------------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------------------------------
Arrotonda!
= _ROUND(num!
* 100) / 100