unit Unit1;

interface

uses
   System.SysUtils, System.Types, System.UITypes, System.Classes,
   System.Variants, System.Generics.Collections,
   FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
   FMX.Controls.Presentation, FMX.StdCtrls;

type
   TForm1 = class(TForm)
      StartP: TSelectionPoint;
      EndP: TSelectionPoint;
      Label1: TLabel;
      Label2: TLabel;
      Selection1: TSelection;
      ControlP1: TSelectionPoint;
      ControlP2: TSelectionPoint;
      Label3: TLabel;
      Label4: TLabel;
      Path1: TPath;
      procedure StartPTrack(Sender: TObject; var X, Y: Single);
      procedure EndPTrack(Sender: TObject; var X, Y: Single);
      procedure ControlP1Track(Sender: TObject; var X, Y: Single);
      procedure ControlP2Track(Sender: TObject; var X, Y: Single);
   private
      { Private declarations }
   public
      { Public declarations }
      procedure updatePathData;
   end;

var
   Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.ControlP1Track(Sender: TObject; var X, Y: Single);
begin
   self.Label3.Position.X := X - 22;
   self.Label3.Position.Y := Y - 30;

   self.updatePathData;
end;

procedure TForm1.ControlP2Track(Sender: TObject; var X, Y: Single);
begin
   self.Label4.Position.X := X - 22;
   self.Label4.Position.Y := Y - 30;

   self.updatePathData;
end;

procedure TForm1.EndPTrack(Sender: TObject; var X, Y: Single);
begin
   self.Label2.Position.X := X - 20;
   self.Label2.Position.Y := Y - 30;

   self.updatePathData;
end;

procedure TForm1.StartPTrack(Sender: TObject; var X, Y: Single);
begin
   self.Label1.Position.X := X - 20;
   self.Label1.Position.Y := Y - 30;

   self.updatePathData;
end;

procedure TForm1.updatePathData;
begin
    self.Path1.Position.X := self.Selection1.Position.X + self.StartP.Position.X;
    self.Path1.Position.Y := self.Selection1.Position.Y + self.StartP.Position.Y;
    self.Path1.Size.Width := abs(self.EndP.Position.X - self.StartP.Position.X);
    self.Path1.Size.Height := abs(self.EndP.Position.Y - self.StartP.Position.Y);

   self.Path1.Data.Clear;

   self.Path1.Data.MoveTo(TPointF.Create(self.Selection1.Position.X + self.StartP.Position.X,
       self.Selection1.Position.Y + self.StartP.Position.Y));

   self.Path1.Data.CurveTo(TPointF.Create(self.Selection1.Position.X + self.ControlP1.Position.X,
       self.Selection1.Position.Y + self.ControlP1.Position.Y),
       TPointF.Create(self.Selection1.Position.X + self.ControlP2.Position.X,
       self.Selection1.Position.Y + self.ControlP2.Position.Y),
       TPointF.Create(self.Selection1.Position.X + self.EndP.Position.X,
       self.Selection1.Position.Y + self.EndP.Position.Y));
end;

end.
