次の方法で共有


StrokeIntersection 構造体

ストロークで交差が開始および終了する場所の浮動小数点インデックス値を表します。

名前空間 :  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 では、構造体を使用できますが、新規に宣言することはできません。

解説

浮動小数点インデックスは、ストローク内の 2 つのポイントの間のある場所を表す浮動小数点値です。たとえば、0.0 がストローク内の最初のポイントで、1.0 がストローク内の 2 番目のポイントの場合、0.5 が最初のポイントと 2 番目のポイントの中間です。同様に、値 37.25 は、ストロークのポイント 37 と 38 の間の線に沿って 25 パーセント進んだ位置を表しています。

StrokeIntersection 構造体の配列を使用して、Stroke オブジェクトに沿う複数の交差部分を示します。

この例では、渡された 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