polytest.pas 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. program PolyTest;
  7. uses
  8. graph;
  9. const
  10. MaxPoints = 1000;
  11. var
  12. InF: Text;
  13. NumPoints: Integer;
  14. Poly: array [1..MaxPoints] of PointType;
  15. procedure ReadPoly;
  16. var
  17. I: Integer;
  18. begin
  19. Readln(InF, NumPoints);
  20. for I := 1 to NumPoints do
  21. Readln(InF, Poly[I].X, Poly[I].Y);
  22. end;
  23. procedure CheckGraphResult;
  24. var
  25. ErrorCode: Integer;
  26. begin
  27. ErrorCode := GraphResult;
  28. if ErrorCode <> grOk then
  29. begin
  30. CloseGraph;
  31. Writeln(ErrorCode, ': ', GraphErrorMsg(ErrorCode));
  32. Readln;
  33. Halt(1);
  34. end;
  35. end;
  36. procedure Tralala;
  37. var
  38. I: Integer;
  39. IStr: string;
  40. begin
  41. if ParamStr(1) <> '' then
  42. Assign(InF, ParamStr(1))
  43. else
  44. Assign(InF, 'polytest.txt');
  45. Reset(InF);
  46. I := 1;
  47. while not Eof(InF) do
  48. begin
  49. ReadPoly;
  50. ClearDevice;
  51. Str(I, IStr);
  52. OutTextXY(0, 0, IStr);
  53. DrawPoly(NumPoints, Poly);
  54. CheckGraphResult;
  55. Readln;
  56. ClearDevice;
  57. OutTextXY(0, 0, IStr + ' fill');
  58. FillPoly(NumPoints, Poly);
  59. CheckGraphResult;
  60. Readln;
  61. Inc(I);
  62. end;
  63. Close(InF);
  64. end;
  65. var
  66. GraphDriver, GraphMode: Integer;
  67. begin
  68. GraphDriver := VGA;
  69. GraphMode := VGAHi;
  70. InitGraph(GraphDriver, GraphMode, '');
  71. SetFillStyle(SolidFill, 9);
  72. Tralala;
  73. CloseGraph;
  74. end.