Declaration
function RulerValue(Aspect: TIERulerAspect = ierDefault): Double;
Description
Returns measurement values for the current layer.
Supported values are as follows:
The unit of
RulerValue is specified by
RulerUnits.
// Display the current length of a line layer
lblLen.Caption := FloatToStr( ImageEnView1.CurrentLayer.RulerValue() );
// Display the area of a text layer
lblSize.Caption := FloatToStr( ImageEnView1.CurrentLayer.RulerValue() );
// Display the length of a text layer boundary (perimeter)
lblSize.Caption := FloatToStr( ImageEnView1.CurrentLayer.RulerValue( ierLength ));
// THREE WAYS TO CALCULATE PERIMETER AND AREA OF AN ELLIPSE
// 1. Shape Layer
ImageEnView1.LayersAdd( iesEllipse, 10, 10, 400, 250 );
ImageEnView1.CurrentLayer.RulerUnits := ieuPixels;
memo1.Lines.Add( 'Shape Perim : ' + FloatToStr( ImageEnView1.CurrentLayer.RulerValue( ierLength )));
memo1.Lines.Add( 'Shape Area : ' + FloatToStr( ImageEnView1.CurrentLayer.RulerValue( ierArea )));
// 2. Text Layer
ImageEnView1.LayersAdd( ielkText, 10, 410, 400, 250 );
ImageEnView1.CurrentLayer.FillColor := clRed;
ImageEnView1.CurrentLayer.RulerUnits := ieuPixels;
ImageEnView1.CurrentLayer.RulerMode := iermLabel;
TIETextLayer( ImageEnView1.CurrentLayer ).BorderShape := iesEllipse;
memo1.Lines.Add( 'Text Perim : ' + FloatToStr( ImageEnView1.CurrentLayer.RulerValue( ierLength )));
memo1.Lines.Add( 'Text Area : ' + FloatToStr( ImageEnView1.CurrentLayer.RulerValue( ierArea )));
// 3. Polyline Layer (less accurate)
ImageEnView1.LayersAdd( iesEllipse, 10, 810, 400, 250 );
TIEShapeLayer( ImageEnView1.CurrentLayer ).ConvertToPolylineLayer();
IEGlobalSettings().LayerCurveQuality := 36; // Less points to reduce complexity
memo1.Lines.Add( 'Poly Perim : ' + FloatToStr( TIEPolylineLayer( ImageEnView1.CurrentLayer ).CalculateLength( ieuPixels )));
memo1.Lines.Add( 'Poly Area : ' + FloatToStr( TIEPolylineLayer( ImageEnView1.CurrentLayer ).CalculateArea( ieuPixels )));
ImageEnView1.Update;
{ Returns:
Shape Perim : 1047.851
Shape Area : 78539.816
Text Perim : 1047.851
Text Area : 78539.816
Poly Perim : 1028.604
Poly Area : 77512.826
}
See Also
◼RulerMode
◼RulerUnits