72 lines
1.3 KiB
Plaintext
72 lines
1.3 KiB
Plaintext
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;
|
|
int N;
|
|
def BarWidth = 0.4;
|
|
[for N:= 0 to Len-1 do
|
|
[Rectangle(Size*BarWidth, List(N)*Size);
|
|
MoveTo(Size*BarWidth);
|
|
];
|
|
MoveTo(-Size*BarWidth*float(Len));
|
|
];
|
|
|
|
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, 45.0);
|
|
]
|