InkStroke InkStroke InkStroke InkStroke InkStroke Class

Definition

A single ink stroke, including the Bézier curve parameters used for final rendering of the stroke.

public : sealed class InkStroke : IInkStroke, IInkStroke2, IInkStroke3
struct winrt::Windows::UI::Input::Inking::InkStroke : IInkStroke, IInkStroke2, IInkStroke3
public sealed class InkStroke : IInkStroke, IInkStroke2, IInkStroke3
Public NotInheritable Class InkStroke Implements IInkStroke, IInkStroke2, IInkStroke3
// This class does not provide a public constructor.
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

Here we iterate through each stroke in an InkManager and process them for final rendering using Bézier curves.

// Iterate through each stroke.
inkManager.getStrokes().forEach(
    function (stroke)
    {
        inkContext.beginPath();
        if (stroke.selected) {
            inkContext.lineWidth = stroke.drawingAttributes.size.width * 2;
            inkContext.strokeStyle = "green";
        } else {
            inkContext.lineWidth = stroke.drawingAttributes.size.width;
            inkContext.strokeStyle = "black";
        }

        // Enumerate through each line segment of the stroke.
        var first = true;

        stroke.getRenderingSegments().forEach(
            function (segment)
            {
                // Move to the starting screen location of the stroke.
                if (first)
                {
                    inkContext.moveTo(segment.position.x, segment.position.y);
                    first = false;
                }
                // Calculate the bezier curve for the segment.
                else
                {
                    inkContext.bezierCurveTo(segment.bezierControlPoint1.x,
                                             segment.bezierControlPoint1.y,
                                             segment.bezierControlPoint2.x,
                                             segment.bezierControlPoint2.y,
                                             segment.position.x, segment.position.y);
                }
            }
        );
        
        // Draw the stroke.
        inkContext.stroke();
        inkContext.closePath();
    }

Remarks

JavaScript (usage)
var inkStrokes = Windows.UI.Input.Inking.InkManager.getStrokes; var inkStroke = inkStrokes[...];
var inkStrokes = Windows.UI.Input.Inking.inkRecognitionResult.getStrokes; var inkStroke = inkStrokes[...];
var inkStrokes = Windows.UI.Input.Inking.inkStrokeContainer.getStrokes; var inkStroke = inkStrokes[...];

Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).

Properties

BoundingRect BoundingRect BoundingRect BoundingRect BoundingRect

Gets the bounding box for the InkStroke.

DrawingAttributes DrawingAttributes DrawingAttributes DrawingAttributes DrawingAttributes

Gets or sets the properties associated with an InkStroke.

Id Id Id Id Id

Gets the ink stroke identifier.

A unique identifier is assigned to each ink stroke managed by the InkPresenter.

PointTransform PointTransform PointTransform PointTransform PointTransform

Gets or sets an affine transformation matrix to apply to the InkStroke object.

Recognized Recognized Recognized Recognized Recognized

Gets whether the stroke is recognized.

Selected Selected Selected Selected Selected

Gets whether the stroke is selected.

StrokeDuration StrokeDuration StrokeDuration StrokeDuration StrokeDuration

Gets or sets the time taken by the user to draw a single ink stroke.

StrokeStartedTime StrokeStartedTime StrokeStartedTime StrokeStartedTime StrokeStartedTime

Gets or sets the date and time when the InkStroke was started.

Methods

Clone() Clone() Clone() Clone() Clone()

Copies the InkStroke to another InkManager (or InkStrokeContainer ).

GetInkPoints() GetInkPoints() GetInkPoints() GetInkPoints() GetInkPoints()

Gets the collection of InkPoint objects used to construct the InkStroke.

GetRenderingSegments() GetRenderingSegments() GetRenderingSegments() GetRenderingSegments() GetRenderingSegments()

Gets the rendering segments of the stroke.

Note

For Universal Windows app using Extensible Application Markup Language (XAML), use GetInkPoints (see remarks).

See also