DelphiDabbler Code Snippets Database

Snippet Selection

The following snippets from the Code Snippets Database have been requested.

DistanceBetweenPoints (TPointF overload)

Calculates the distance between two given points with double precision floating point valued coordinates.

function DistanceBetweenPoints(const P1, P2: TPointF): Extended; overload;
begin
  Result := Math.Hypot(P1.X - P2.X, P1.Y - P2.Y);
end;

DistanceBetweenPoints (TPoint overload)

Calculates the distance between two points with integer valued co-ordinates.

function DistanceBetweenPoints(const P1, P2: Types.TPoint): Extended; overload;
begin
  Result := Math.Hypot(P1.X - P2.X, P1.Y - P2.Y);
end;

RectArea

Returns the area of the given rectangle.

function RectArea(const R: Windows.TRect): Int64;
begin
  Result := Abs((R.Right - R.Left) * (R.Bottom - R.Top));
end;

View the whole database.

Go to the DelphiDabbler website.