Share via


Stroke.GetRectangleIntersections Method

Stroke.GetRectangleIntersections Method

Returns an array of Point Leave Site structures that indicate where a Stroke object intersects a given Rectangle Leave Site.

Definition

Visual Basic .NET Public Function GetRectangleIntersections( _
ByVal intersectRectangle As Rectangle _
) As StrokeIntersection()
C# public StrokeIntersection[] GetRectangleIntersections(
Rectangle intersectRectangle
);
Managed C++ public: StrokeIntersection* GetRectangleIntersections(
Rectangle *intersectRectangle
) __gc[];

Parameters

intersectRectangle System.Drawing.Rectangle. The Rectangle Leave Site structure, in ink space coordinates, that describes the hit test area.

Return Value

Microsoft.Ink.StrokeIntersection[]. Returns an array of Point Leave Site structures that indicate where a Stroke object intersects the intersectRectangle parameter.

Remarks

This method returns at least one set of indices that represent the beginning and the end of the segments of the stroke that intersect the rectangle. If a stroke passes straight through a rectangle, interecting the boundary in two places, the set of indices are made of the floating point index values for each intersection. If a stroke intersects a rectangle more than two times, the number of indices is increased by the number of intersections.

If the stroke begins within the test rectangle, the BeginIndex property of the first StrokeIntersection element is set to -1. If the stroke ends within the test rectangle, the EndIndex property of the last StrokeIntersection element is set to -1. If the stroke is wholly outside the test rectangle, an empty StrokeIntersection array is returned. For example, if a stroke begins inside the test rectangle, leaves the boundaries of the rectangle, returns inside, and leaves again, then the GetRectangleIntersections method might return {{-1, 1.4}, {5.5, 10.1}} to describe the two segments of the stroke falling within the rectangle.

This method returns an array of floating point index values that indicate the locations where the intersections occur. 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 gets the array of beginning and end points of the sections of the Stroke object, theStroke, that is intersected by the Rectangle Leave Site structure, theRectangle. The points in the array are floating point index values that are stored in a StrokeIntersection structure.

StrokeIntersection[] theSegments = theStroke.GetRectangleIntersections(theRectangle);
                

[VB.NET]

This Microsoft® Visual Basic® .NET example gets the array of beginning and end points of the sections of the Stroke object, theStroke, that is intersected by the Rectangle Leave Site structure, theRectangle. The points in the array are floating point index values that are stored in a StrokeIntersection structure.

Dim theSegments() As StrokeIntersection
theSegments = theStroke.GetRectangleIntersections(theRectangle)
                

See Also