TPoint (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code example illustrates the behavior of the TPoint.Add, TPoint.Subtract and TPoint.Distance methods.

Code

procedure math;
var
  P1, P2, P3: TPoint; 
begin
  P1 := Point(2, 16); 
  P2 := Point(5, 33); 

  P3 := P2 - P1;
  writeln('Subtraction Coordinates. X:',  P3.X, ' Y:', P3.Y);
  P3 := P1 + P2;
  writeln('Addition Coordinates. X:',P3.X, ' Y:', P3.Y);
  writeln('Distance between the two new points:', (P2 - P1).Distance(P1 + P2));
end;

Uses