unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, TeEngine, Series, TeeProcs, Chart;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Button1: TButton;
    Image1: TImage;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var x1,x2,x3,x4,y1,y2,y3,y4,maxi,maxj:integer;
    k,d1,d2,d3,d4:extended;
    f1,f2,f3:boolean;
begin
with image1.Canvas do
begin
    pen.Color:= clwhite;
    Brush.Color := clwhite;
    polygon([point(0,0),point(0,600),point(1200,600),point(1200,0)]);
  end;
Edit1.Text:='10';
Edit2.Text:='10';
Edit3.Text:='-10';
Edit4.Text:='10';
Edit5.Text:='-10';
Edit6.Text:='-10';
Edit7.Text:='10';
Edit8.Text:='-10';
f1:=FALSE; //параллельность
f2:=FALSE; //равенство всех сторон
f3:=FALSE; //диагонали под прямым
x1:=strtoint(edit1.text);
y1:=strtoint(edit2.text);
x2:=strtoint(edit3.text);
y2:=strtoint(edit4.text);
x3:=strtoint(edit5.text);
y3:=strtoint(edit6.text);
x4:=strtoint(edit7.text);
y4:=strtoint(edit8.text);

d1:=sqrt(sqr(x1-x2)+sqr(y1-y2));
d2:=sqrt(sqr(x3-x2)+sqr(y3-y2));
d3:=sqrt(sqr(x4-x3)+sqr(y4-y3));
d4:=sqrt(sqr(x1-x4)+sqr(y1-y4));

 if (d1=d3) and (d4=d2) and (d2=d3) then f2:=true;
 if 0=((x3-x4)*(x3-x2) + (y3-y4)*(y3-y2)) then f3:=true;
 if f2 then label9.Caption:=('квадрат')
 else if f1 then label10.Caption:=('трапеция')
  else if f3 then label11.Caption:=('ромб');



if ((x2-x1)<>0)and((x3-x4)<>0)
  then
    if ((y2-y1)/(x2-x1))=((y3-y4)/(x3-x4)) then f1:=true
  else
    if ((x2-x1)=0)and((x3-x4)=0) then f1:=true;

 if ((x3-x2)<>0)and((x4-x1)<>0)
  then
    if ((y3-y2)/(x3-x2))=((y4-y1)/(x4-x1)) then f1:=true
  else
    if ((x3-x2)=0)and((x4-x1)=0) then f1:=true;



maxi:=x1;
 if maxi<x2 then maxi:=x2;
 if maxi<x3 then maxi:=x3;
 if maxi<x4 then maxi:=x4;

 maxj:=y1;
 if maxj<y2 then maxj:=y2;
 if maxj<y3 then maxj:=y3;
 if maxj<y4 then maxj:=y4;

 if maxi>(maxj*2) then k:=maxi
                  else k:=maxj;

 x1:=trunc(x1*k)+200;
 y1:=trunc(y1*k)+100;
 x2:=trunc(x2*k)+200;
 y2:=trunc(y2*k)+100;
 x3:=trunc(x3*k)+200;
 y3:=trunc(y3*k)+100;
 x4:=trunc(x4*k)+200;
 y4:=trunc(y4*k)+100;



 with image1.Canvas do
  begin
    pen.Color:=clblack;
    Brush.Color:=clred;
    polygon([point(x1,y1),point(x2,y2),point(x3,y3),point(x4,y4)]);
  end;
end;
end.
