Offset (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code example shows the usage of the TPointF.Offset and TPoint.Offset methods.

Code

uses
  System.SysUtils,
  System.Types;

var
  aPoint1: TPoint;
  aPoint2: TPointF;

begin
  aPoint1 := Point(2, 8);
  aPoint2 := PointF(5.77, 33.12);

  aPoint1.Offset(5, 7);
  aPoint2.Offset(4.9, 3.3);
  writeln('aPoint X coordinate:', aPoint1.X);
  writeln('aPoint Y coordinate:', aPoint1.Y);

  writeln('aPoint2 X coordinate:', Format('%2.2f', [aPoint2.X]));
  writeln('aPoint2 Y coordinate:', Format('%2.2f', [aPoint2.Y]));
  readln;

end.

Uses