Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.00 KB | None | 0 0
  1. type
  2.     TForm1 = class(TForm)
  3.         Button1: TButton;
  4.         Button2: TButton;
  5.         procedure Button1Click(Sender: TObject);
  6.         procedure Button2Click(Sender: TObject);
  7.         procedure FormCreate(Sender: TObject);
  8.     private
  9.         const n = 20;
  10.         p: array of point;
  11.     public
  12.     end;
  13.  
  14. var Form1: TForm1;
  15.  
  16. implementation
  17.  
  18. {$R *.dfm}
  19.  
  20. procedure TForm1.FormCreate(Sender: TObject);
  21. var
  22.     cx, cy, i: integer;
  23.     a: real;
  24. begin
  25.     setlength(p, n);
  26.     a := 0;
  27.     cx := Form1.GetWidth div 2;
  28.     cy := Form1.GetHeight div 2;
  29.  
  30.     for i := 0 to n - 1 do
  31.     begin
  32.         p[i].x := cx + round(240 * cos(a));
  33.         p[i].y := cy + round(240 * sin(a));
  34.         a := a + 2 * Pi / n;
  35.     end;
  36. end;
  37.  
  38. procedure TForm1.Button1Click(Sender: TObject);
  39. var
  40.     i, j: integer;
  41. begin
  42.     With Form1.Canvas do
  43.     begin
  44.         Poligon(p);
  45.         for i := 0 to n - 1 do
  46.             for j := 0 to n - 1 do
  47.                 if i <> j then
  48.                 begin
  49.                     MoveTo(p[i].x, p[i].y);
  50.                     LineTo(p[j].x, p[j].y);
  51.                 end;
  52.     end;
  53. end;
  54.  
  55. procedure TForm1.Button2Click(Sender: TObject);
  56. begin
  57.     Form1.Close;
  58. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement