共用方式為


Stroke.NearestPoint Method

Stroke.NearestPoint Method

Returns the location on the Stroke object nearest to a specified Point Leave Site and the distance between the point and the Stroke object.

Definition

Visual Basic .NET Public Function NearestPoint( _
ByVal pt As Point, _
ByRef distance As Single _
) As Single
C# public float NearestPoint(
Point pt,
out float distance
);
Managed C++ public: float* NearestPoint(
Point *pt,
float **distance
);

Parameters

pt System.Drawing.Point. The specified point, in ink space coordinates.
distance System.Single. The distance from the point to the Stroke object, as a floating point index.

Return Value

System.Single. Returns the location on the Stroke object nearest to a specified Point Leave Site.

Remarks

A floating point index is a float value that represents a location somewhere between two points in the Stroke object. As examples, if 0.0 is the first point in the stroke and 1.0 is the second point in the stroke, 0.5 is halfway between the first and second points. Similarly, a floating point index value of 37.25 represents a location that is 25 percent along the line between points 37 and 38 of the stroke.

Examples

[C#]

This C# example returns the nearest location on the Stroke object, theStroke, to the Point Leave Site, theInkSpacePoint. This overload also gets the distance between those two points, theDistance.

float theDistance;
float theFIndex = theStroke.NearestPoint(theInkSpacePoint, out theDistance);
                

[VB.NET]

This Microsoft® Visual Basic® .NET example returns the nearest location on the Stroke object, theStroke, to the Point Leave Site, theInkSpacePoint. This overload also gets the distance between those two points, theDistance.

Dim theDistance As Single
Dim theFIndex As Single = theStroke.NearestPoint(theInkSpacePoint, theDistance)
                

See Also