다음을 통해 공유


StrokeIntersection 구조체

업데이트: 2007년 11월

스트로크에서 교차가 시작되어 끝나는 부동 소수점 인덱스 값을 나타냅니다.

네임스페이스:  Microsoft.Ink
어셈블리:  Microsoft.Ink(Microsoft.Ink.dll)

구문

‘선언
Public Structure StrokeIntersection
‘사용 방법
Dim instance As StrokeIntersection
public struct StrokeIntersection
public value class StrokeIntersection
public final class StrokeIntersection extends ValueType
JScript에서는 구조체를 사용할 수 있지만 새로 선언할 수는 없습니다.

설명

부동 소수점 인덱스는 스트로크의 두 점 사이에 있는 위치를 나타내는 부동 소수점 값입니다. 예를 들어 스트로크에서 첫 번째 점이 0.0이고 두 번째 점이 1.0인 경우 0.5는 첫 번째 점과 두 번째 점 사이의 중간 지점입니다. 마찬가지로 값 37.25는 스트로크의 37번과 38번 점 사이의 선에서 25% 위치를 나타냅니다.

Stroke 개체의 여러 교차 지점을 나타내려면 StrokeIntersection 구조체 배열을 사용합니다.

예제

이 예제에서는 전달된 Stroke 개체의 세그먼트 중 지정된 Rectangle 구조체 안에 있는 모든 세그먼트가 삭제됩니다. 이를 위해 StrokeIntersection 구조체를 조사하여 전달된 Stroke 개체를 분할할 위치 및 삭제할 세그먼트를 확인합니다.

Private Sub DeleteInsideRectangle(ByVal S As Stroke, ByVal R As Rectangle)
    ' get the StrokeIntersection array
    Dim SI() As StrokeIntersection = S.GetRectangleIntersections(R)
    ' examine each StrokeIntersection
    ' must work backwards through the array so that when splitting, 
    ' the remaining intersections are still valid for S
    For k As Integer = SI.Length - 1 To 0 Step -1

        Dim enterRect As Single = SI(k).BeginIndex
        Dim exitRect As Single = SI(k).EndIndex

        ' check if the whole stroke is inside the rectangle
        ' if so, delete the stroke
        If enterRect = -1 And exitRect = -1 Then
            S.Ink.DeleteStroke(S)
            Continue For
        End If

        ' check if a segment enters and exits the rectangle
        ' if so, split and delete the segment inside the rectangle
        If enterRect > 0 And exitRect > 0 Then
            ' the stroke resulting from split() is outside, keep it
            S.Split(exitRect)
            ' the stroke from this split() is inside, delete it
            Dim temp As Stroke = S.Split(enterRect)
            temp.Ink.DeleteStroke(temp)
            Continue For
        End If

        ' check if stroke starts inside the rectangle and goes outside
        ' if so, split and delete the segment inside the rectangle
        If enterRect = -1 And exitRect > 0 Then
            ' the stroke resulting from split() is outside, keep it
            S.Split(exitRect)
            ' delete the remaining segment of the stroke
            S.Ink.DeleteStroke(S)
            Continue For
        End If

        ' check if stroke starts outside the rectangle and ends inside
        ' if so, split and delete the segment inside the rectangle
        If enterRect > 0 And exitRect = -1 Then
            Dim temp2 As Stroke = S.Split(enterRect)
            temp2.Ink.DeleteStroke(temp2)
        End If
    Next
End Sub
private void DeleteInsideRectangle(Stroke S, Rectangle R)
{
    // get the StrokeIntersection array
    StrokeIntersection[] SI = S.GetRectangleIntersections(R);

    // examine each StrokeIntersection
    // must work backwards through the array so that when splitting, 
    // the remaining intersections are still valid for S
    for (int k = SI.Length - 1; k >= 0; k--)
    {
        float enterRect = SI[k].BeginIndex;
        float exitRect = SI[k].EndIndex;

        // check if the whole stroke is inside the rectangle
        // if so, delete the stroke
        if (enterRect == -1 && exitRect == -1)
        {
            S.Ink.DeleteStroke(S);
            continue;
        }

        // check if a segment enters and exits the rectangle
        // if so, split and delete the segment inside the rectangle
        if (enterRect > 0 && exitRect > 0)
        {
            // the stroke resulting from split() is outside, keep it
            S.Split(exitRect);
            // the stroke from this split() is inside, delete it
            Stroke temp = S.Split(enterRect);
            temp.Ink.DeleteStroke(temp);
            continue;
        }

        // check if stroke starts inside the rectangle and goes outside
        // if so, split and delete the segment inside the rectangle
        if (enterRect == -1 && exitRect > 0)
        {
            // the stroke resulting from split() is outside, keep it
            S.Split(exitRect);
            // delete the remaining segment of the stroke
            S.Ink.DeleteStroke(S);
            continue;
        }

        // check if stroke starts outside the rectangle and ends inside
        // if so, split and delete the segment inside the rectangle
        if (enterRect > 0 && exitRect == -1)
        {
            Stroke temp2 = S.Split(enterRect);
            temp2.Ink.DeleteStroke(temp2);
        }
    }
}

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows Vista

.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

StrokeIntersection 멤버

Microsoft.Ink 네임스페이스

Stroke.GetRectangleIntersections