Compartilhar via


Stroke.Split Method

Stroke.Split Method

Splits the Stroke object at the specified location on the Stroke object and returns the new Stroke object.

Definition

Visual Basic .NET Public Function Split( _
ByVal findex As Single _
) As Stroke
C# public Stroke Split(
float findex
);
Managed C++ public: Stroke* Split(
float *findex
);

Parameters

findex System.Single. The floating point index value that represents where to split the Stroke object.

Return Value

Microsoft.Ink.Stroke. The new Stroke object that is created as a result of calling this method.

Remarks

A floating point index is a float value that represents a location somewhere between two points in the stroke. 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.

When a Stroke is split, one portion of the stroke retains the Id property of the original Stroke object. The other portion of the Stroke becomes a new Stroke object with an Id property that is one greater than the highest existing Id property. If the original Stroke was in a Strokes collection (other than the Ink.Strokes), only the beginning portion remains in that collection.

Examples

[C#]

This C# example splits a Stroke object, theStroke, in half and renders the second half green.

float halfIndex = 0.5f * theStroke.GetPoints().Length;
Stroke endStroke = theStroke.Split(halfIndex);
endStroke.DrawingAttributes.Color = Color.Green;
                

[VB.NET]

This Microsoft® Visual Basic® .NET example splits a Stroke object, theStroke, in half and renders the second half green.

Dim halfIndex As Single = theStroke.GetPoints().Length / 2
Dim endStroke As Stroke = theStroke.Split(halfIndex)
endStroke.DrawingAttributes.Color = Color.Green
                

[C#]

This C# example splits the first Stroke object in a Strokes collection, theStrokes, in half, and then adds the newly created Stroke object back into theStrokes.

float halfIndex = 0.5f * theStrokes[0].GetPoints().Length;
Stroke endStroke = theStrokes[0].Split(halfIndex);
theStrokes.Add(endStroke);
                

[VB.NET]

This Visual Basic .NET example splits the first Stroke object in a Strokes collection, theStrokes, in half, and then adds the newly created Stroke object back into theStrokes.

Dim halfIndex As Single = theStrokes(0).GetPoints().Length / 2
Dim endStroke As Stroke = theStrokes(0).Split(halfIndex)
theStrokes.Add(endStroke)