ImageEn, unit imageenview

TImageEnView.CalcSelectionCentroid

TImageEnView.CalcSelectionCentroid

Declaration

function CalcSelectionCentroid(): TPoint;

Description

Calculates the coordinates of the selection's centroid (in bitmap coordinates).
The centroid is the geometric center of a shape, i.e. the mean position of all the points in the figure.

Note: Works with all selection types, including selection masks

Demo

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr

Example

// Show statistics while making a selection
procedure TfrmMain.ImageEnView1SelectionChanging(Sender: TObject);
const
  Units = ieuPixels;
var
  uS: string;
begin
  uS := IEGlobalSettings().MeasureUnits[ Units ];

  Label1.Caption := format( 'Area: %.2f %sē', [ ImageEnView1.CalcSelectionArea( Units ), uS ]);
  Label2.Caption := format( 'Perimeter: %.2f %s',[ ImageEnView1.CalcSelectionLen( Units ), uS ]);
  Label3.Caption := format( 'Centroid: %d,%d', [ ImageEnView1.CalcSelectionCentroid.X, ImageEnView1.CalcSelectionCentroid.Y ]);
end;

See Also

CalcSelectionArea
CalcSelectionLen
MeasureUnits