RosettaCodeData/Task/Plot-coordinate-pairs/Liberty-BASIC/plot-coordinate-pairs-2.basic

64 lines
1.1 KiB
Plaintext

nomainwin
DATA 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
DATA 2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0
For i = 0 To 9
READ tmp: x( i) = tmp
Next i
For i = 0 To 9
READ tmp: y( i) = tmp
Next i
'Plotting coordinate pairs
WindowHeight = 500
WindowWidth = 430
Open "Plot coordinate pairs" For Graphics_nsb_nf As #gwin
#gwin "trapclose [quit.gwin]"
#gwin "Color Black; Down"
'25, 418 is 0,0
global offsetX, offsetY, scaleX, scaleY
offsetX = 25: offsetY = 418
scaleX = 40: scaleY = 2
maxX = 9: maxY = 200
#gwin "line "; sx( maxX);" "; sy( 0);" "; sx( 0); " "; sy( 0)
#gwin "goto "; sx( 0); " "; sy( maxY)
For x = 0 To 9
#gwin "place ";sx(x);" ";sy(0)
#gwin "Go -18"
#gwin "|"; x
Next
#gwin "turn 90"
For y = 0 To 200 Step 20
#gwin "place ";sx(0);" ";sy(y)
#gwin "Go -5"
#gwin "place ";0;" ";sy(y)
#gwin "|"; y
Next
#gwin "size 3"
For i = 0 To 9
#gwin "set ";sx(x(i));" ";sy(y(i))
Next i
#gwin "Flush"
Wait
[quit.gwin]
Close #gwin
End
'x, y to screen x, y
function sx(x)
sx = offsetX +x*scaleX
end function
function sy(y)
sy = offsetY-y*scaleY 'y is inverted
end function