Skip to main content

LineCenter

Returns a point that corresponds to the center of a polyline.

Unit

dxLines

function LineCenter(LType: TLineType; var Points; Count: Integer): TPoint;

Use this function to get a point that corresponds to the center of a polyline. LType determines line type. The Points parameter represents a pointer to an array that contains coordinates of vertices. Count specifies the number of vertices in a polyline. The following example demonstrates the LineCenter implementation:

var
  Pnts : array [0..3] of TPoint;
  Pnt : TPoint;
{ . . . }
implementation
{ . . . }
  Pnts[0].x := 10; Pnts[0].y := 10;
  Pnts[1].x := 20; Pnts[1].y := 10;
  Pnts[2].x := 20; Pnts[2].y := 20;
  Pnts[3].x := 10; Pnts[3].y := 20;
  // returns point (20, 15)
  Pnt := LineCenter(liStraight, Pnts ,4);
{ . . . }

Note

To use this function, you should include:

Lines‘ in the uses section of a unit (for Delphi) or

‘#include Lines.hpp‘ in the header file (for C++ Builder)

See Also