1 {
2  test for graph unit's DrawPoly and FillPoly procedures
3  compiles with Turbo Pascal 7 and Free Pascal
4  used for TP7 compatibily testing
5 }
6 
7 program PolyTest;
8 
9 uses
10   graph;
11 
12 const
13   MaxPoints = 1000;
14 
15 var
16   InF: Text;
17   NumPoints: Integer;
18   Poly: array [1..MaxPoints] of PointType;
19 
20 procedure ReadPoly;
21 var
22   I: Integer;
23 begin
24   Readln(InF, NumPoints);
25   for I := 1 to NumPoints do
26     Readln(InF, Poly[I].X, Poly[I].Y);
27 end;
28 
29 procedure CheckGraphResult;
30 var
31   ErrorCode: Integer;
32 begin
33   ErrorCode := GraphResult;
34   if ErrorCode <> grOk then
35   begin
36     CloseGraph;
37     Writeln(ErrorCode, ': ', GraphErrorMsg(ErrorCode));
38     Readln;
39     Halt(1);
40   end;
41 end;
42 
43 procedure Tralala;
44 var
45   I: Integer;
46   IStr: string;
47 begin
48   if ParamStr(1) <> '' then
49     Assign(InF, ParamStr(1))
50   else
51     Assign(InF, 'polytest.txt');
52   Reset(InF);
53   I := 1;
54   while not Eof(InF) do
55   begin
56     ReadPoly;
57     ClearDevice;
58     Str(I, IStr);
59     OutTextXY(0, 0, IStr);
60     DrawPoly(NumPoints, Poly);
61     CheckGraphResult;
62     Readln;
63 
64     ClearDevice;
65     OutTextXY(0, 0, IStr + ' fill');
66     FillPoly(NumPoints, Poly);
67     CheckGraphResult;
68     Readln;
69     Inc(I);
70   end;
71   Close(InF);
72 end;
73 
74 var
75   GraphDriver, GraphMode: Integer;
76 begin
77   GraphDriver := VGA;
78   GraphMode := VGAHi;
79   InitGraph(GraphDriver, GraphMode, '');
80   SetFillStyle(SolidFill, 9);
81   Tralala;
82   CloseGraph;
83 end.
84