Data update
This commit is contained in:
parent
8f05c7136f
commit
0bf4da02c3
82 changed files with 2194 additions and 118 deletions
73
Task/Simple-turtle-graphics/XPL0/simple-turtle-graphics.xpl0
Normal file
73
Task/Simple-turtle-graphics/XPL0/simple-turtle-graphics.xpl0
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
def ScrW=320, ScrH=200;
|
||||
def Pi = 3.141592654;
|
||||
def D2R = Pi/180.0;
|
||||
real Dir, PosX, PosY;
|
||||
int Pen;
|
||||
def \Pen\ Up, Down;
|
||||
|
||||
proc Turn(Ang);
|
||||
real Ang;
|
||||
Dir:= Dir + Ang*D2R;
|
||||
|
||||
proc MoveTo(Dist);
|
||||
real Dist;
|
||||
[PosX:= PosX + Dist*Cos(Dir);
|
||||
PosY:= PosY + Dist*Sin(Dir);
|
||||
if Pen = Down then
|
||||
Line(ScrW/2+fix(PosX), ScrH/2-fix(PosY), $0F \white\)
|
||||
else
|
||||
Move(ScrW/2+fix(PosX), ScrH/2-fix(PosY));
|
||||
];
|
||||
|
||||
proc Rectangle(Width, Height);
|
||||
real Width, Height;
|
||||
int N;
|
||||
[for N:= 1 to 2 do
|
||||
[MoveTo(Width);
|
||||
Turn(90.0);
|
||||
MoveTo(Height);
|
||||
Turn(90.0);
|
||||
];
|
||||
];
|
||||
|
||||
proc BarGraph(List, Len, Size);
|
||||
real List; int Len; real Size;
|
||||
real PosX0;
|
||||
int N;
|
||||
def BarWidth = 0.4;
|
||||
[PosX0:= PosX;
|
||||
for N:= 0 to Len-1 do
|
||||
[Rectangle(Size*BarWidth, List(N)*Size);
|
||||
MoveTo(Size*BarWidth);
|
||||
];
|
||||
PosX:= PosX0;
|
||||
];
|
||||
|
||||
proc Triangle(Size);
|
||||
real Size;
|
||||
int N;
|
||||
[for N:= 1 to 3 do
|
||||
[MoveTo(Size);
|
||||
Turn(-120.0);
|
||||
];
|
||||
];
|
||||
|
||||
proc Square(Size);
|
||||
real Size;
|
||||
Rectangle(Size, Size);
|
||||
|
||||
proc House(Size);
|
||||
real Size;
|
||||
[Turn(180.0);
|
||||
Square(Size);
|
||||
Triangle(Size);
|
||||
Turn(180.0);
|
||||
];
|
||||
|
||||
[SetVid($13); \set VGA graphics
|
||||
Move(ScrW/2, ScrH/2); \start Line at center
|
||||
Dir:= 0.0; PosX:= 0.0; PosY:= 0.0; Pen:= Down;
|
||||
House(80.0);
|
||||
Pen:= Up; MoveTo(10.0); Pen:= Down;
|
||||
BarGraph([0.5, 1.0/3.0, 2.0, 1.3, 0.5], 5, 50.0);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue