unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  x1,x2,y1,y2,x31,x32,y31,y32,x41,x42,y41,y42,b,x33,y33,x43,y43:integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
x1:=strtoint(edit1.text);
y1:=strtoint(edit2.text);
x2:=strtoint(edit3.text);
y2:=strtoint(edit4.text);
//определяем расположение оставшихся 2 точек
if x2<x1 then begin
   b:=x2;
   x2:=x1;
   x1:=b; end;

if x2>x1 then
 if y2<y1 then begin
  x31:=x2-(y2-y1);
  y31:=y2+(x2-x1);
  x32:=x2+(y2-y1);
  y32:=y2-(x2-x1);
  x41:=x1-(y2-y1);
  y41:=y1+(x2-x1);
  x42:=x1+(y2-y1);
  y42:=y1-(x2-x1);
  end;

if x2>x1 then
 if y2>y1 then begin
  x31:=x2+(y1-y2);
  y31:=y2+(x2-x1);
  x32:=x2-(y1-y2);
  y32:=y2-(x2-x1);
  x41:=x1+(y1-y2);
  y41:=y1+(x2-x1);
  x42:=x1-(y1-y2);
  y42:=y1-(x2-x1);
  end;

image1.Width:=x31+x32 ;
image1.height:=y31+y32 ;

  //рисуем квадраты
    with  image1.Canvas do begin
 moveto(x1,y1);
 lineto(x2,y2);
 lineto(x31,y31);
 lineto(x41,y41);
 lineto(x1,y1);
  moveto(x1,y1);
 lineto(x42,y42);
 lineto(x32,y32);
 lineto(x2,y2);

 x33:=(x31+x1) div 2;
 y33:=(y31+y1) div 2;
 x43:=(x42+x2) div 2;
 y43:=(y42+y2) div 2;
  moveto(x1,y1);
  lineto(x43,y43);
  lineto(x2,y2);
  lineto(x33,y33);
  lineto(x1,y1);


end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.text:='50';
edit2.text:='60';
edit3.text:='70';
edit4.text:='80';
end;

end.
