tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
34
Task/Plot-coordinate-pairs/XPL0/plot-coordinate-pairs.xpl0
Normal file
34
Task/Plot-coordinate-pairs/XPL0/plot-coordinate-pairs.xpl0
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
|
||||
def ScrW=640, ScrH=480, VidMode=$101;
|
||||
def Sx = ScrW/10, \pixels per horz grid line
|
||||
Sy = ScrH/10, \pixels per vert grid line
|
||||
Ox = (3+1+1)*8+2, \offset for horz grid: allow room for "180.0"
|
||||
Oy = ScrH-20; \offset for vert grid: allow room for labels
|
||||
int X, DataX;
|
||||
real Y, DataY, Gain;
|
||||
def Brown=6, LCyan=11;
|
||||
|
||||
[DataX:= [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
DataY:= [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0];
|
||||
|
||||
SetVid(VidMode);
|
||||
for X:= 0 to 9 do \draw grid
|
||||
[Move(X*Sx+Ox, Oy); Line(X*Sx+Ox, Oy-9*Sy, Brown); \vert lines
|
||||
Move(Ox, Oy-X*Sy); Line(9*Sx+Ox, Oy-X*Sy, Brown); \horz lines
|
||||
];
|
||||
Format(3,1); Attrib(LCyan); \label grid
|
||||
Y:= 0.0;
|
||||
for X:= 0 to 9 do
|
||||
[Move(X*Sx+Ox-3, Oy+6); IntOut(6, X); \X axis
|
||||
Move(0, Oy-X*Sy-7); RlOut(6, Y); \Y axis
|
||||
Y:= Y + 20.0;
|
||||
];
|
||||
Gain:= float(Sy)/20.0;
|
||||
Move(DataX(0)*Sx+Ox, Oy-Fix(DataY(0)*Gain)); \plot points
|
||||
for X:= 1 to 9 do
|
||||
Line(DataX(X)*Sx+Ox, Oy-Fix(DataY(X)*Gain), LCyan);
|
||||
|
||||
if ChIn(1) then []; \wait for key
|
||||
SetVid(3); \restore text
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue