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, IInkStroke3public sealed class InkStroke : IInkStroke, IInkStroke2, IInkStroke3Public NotInheritable Class InkStroke Implements IInkStroke, IInkStroke2, IInkStroke3// You can use this class in JavaScript.
- Attributes
| 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
Gets the bounding box for the InkStroke.
public : Rect BoundingRect { get; }public Rect BoundingRect { get; }Public ReadOnly Property BoundingRect As Rect// You can use this property in JavaScript.
- See Also
DrawingAttributes DrawingAttributes DrawingAttributes DrawingAttributes
Gets or sets the properties associated with an InkStroke.
public : InkDrawingAttributes DrawingAttributes { get; set; }public InkDrawingAttributes DrawingAttributes { get; set; }Public ReadWrite Property DrawingAttributes As InkDrawingAttributes// You can use this property in JavaScript.
The drawing attributes.
Examples
The following example demonstrates how to set a drawing attribute for a specific stroke.
Note
You cannot set the DrawingAttributes property of the stroke directly. You must create a copy of the InkDrawingAttributes of the stroke, set the desired values for that InkDrawingAttributes object, and then assign the new InkDrawingAttributes to the DrawingAttributes of the stroke, as shown here.
inkManager.getStrokes().forEach(function (stroke)
{
var drawingAttributes = stroke.drawingAttributes;
drawingAttributes.penTip =
Windows.UI.Input.Inking.PenTipShape.rectangle;
stroke.drawingAttributes = drawingAttributes;
}
// Get the InkStroke objects.
IReadOnlyList<InkStroke> inkStrokes = inkManager.GetStrokes();
Windows.UI.Input.Inking.InkStroke cloneStroke =
inkStrokes.GetAt(index).Clone();
Windows.UI.Input.Inking.InkDrawingAttributes drawingAttributes =
cloneStroke.DrawingAttributes;
drawingAttributes.PenTip = Windows.UI.Input.Inking.PenTipShape.Rectangle;
cloneStroke.DrawingAttributes = drawingAttributes;
For the complete example, see Ink App sample.
- See Also
Id Id Id Id
Gets the Global Unique Identifier (GUID) that identifies the ink stroke.
A GUID is assigned to each ink stroke managed by the InkPresenter.
public : unsigned int Id { get; }public uint Id { get; }Public ReadOnly Property Id As uint// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The unique identifier for the ink stroke.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Remarks
This GUID persists through serialization/deserialization of the ink stroke.
PointTransform PointTransform PointTransform PointTransform
Gets or sets an affine transformation matrix to apply to the InkStroke object.
public : Matrix3x2 PointTransform { get; set; }public Matrix3x2 PointTransform { get; set; }Public ReadWrite Property PointTransform As Matrix3x2// You can use this property in JavaScript.
- Value
- Matrix3x2 Matrix3x2 Matrix3x2 Matrix3x2
The 2-D transformation matrix.
- See Also
Recognized Recognized Recognized Recognized
Gets whether the stroke is recognized.
public : PlatForm::Boolean Recognized { get; }public bool Recognized { get; }Public ReadOnly Property Recognized As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the stroke is recognized; otherwise, false.
- See Also
Selected Selected Selected Selected
Gets whether the stroke is selected.
public : PlatForm::Boolean Selected { get; set; }public bool Selected { get; set; }Public ReadWrite Property Selected As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the stroke is selected; otherwise, false.
- See Also
StrokeDuration StrokeDuration StrokeDuration StrokeDuration
Gets or sets the time taken by the user to draw a single ink stroke.
public : IReference<TimeSpan> StrokeDuration { get; set; }public Nullable<TimeSpan> StrokeDuration { get; set; }Public ReadWrite Property StrokeDuration As Nullable<TimeSpan>// You can use this property in JavaScript.
- Value
- IReference<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan>
The time period expressed in 100-nanosecond units.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
StrokeStartedTime StrokeStartedTime StrokeStartedTime StrokeStartedTime
Gets or sets the date and time when the InkStroke was started.
public : IReference<DateTime> StrokeStartedTime { get; set; }public Nullable<DateTimeOffset> StrokeStartedTime { get; set; }Public ReadWrite Property StrokeStartedTime As Nullable<DateTimeOffset>// You can use this property in JavaScript.
- Value
- IReference<DateTime> Nullable<DateTimeOffset> Nullable<DateTimeOffset> Nullable<DateTimeOffset>
The date and time of day.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Methods
Clone() Clone() Clone() Clone()
Copies the InkStroke to another InkManager (or InkStrokeContainer ).
public : InkStroke Clone()public InkStroke Clone()Public Function Clone() As InkStroke// You can use this method in JavaScript.
Remarks
This method must be used with AddStroke (InkManager ) or AddStroke (InkStrokeContainer ).
inkStrokeContainer.AddStroke(stroke.Clone());
inkManager.AddStroke(stroke.Clone());
inkStrokeContainer.AddStroke(stroke.Clone());
inkManager.AddStroke(stroke.Clone());
- See Also
GetInkPoints() GetInkPoints() GetInkPoints() GetInkPoints()
Gets the collection of InkPoint objects used to construct the InkStroke.
public : IVectorView<InkPoint> GetInkPoints()public IReadOnlyList<InkPoint> GetInkPoints()Public Function GetInkPoints() As IReadOnlyList( Of InkPoint )// You can use this method in JavaScript.
- See Also
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).
public : IVectorView<InkStrokeRenderingSegment> GetRenderingSegments()public IReadOnlyList<InkStrokeRenderingSegment> GetRenderingSegments()Public Function GetRenderingSegments() As IReadOnlyList( Of InkStrokeRenderingSegment )// You can use this method in JavaScript.
The collection of InkStrokeRenderingSegment objects.
Remarks
If FitToCurve is set to true, this method returns an InkStrokeRenderingSegment that approximates the Bezier curve of the stroke.
If FitToCurve is set to false, this method returns a collection of InkStrokeRenderingSegment objects that represent the original raw pointer data as line segments.
For Universal Windows app using Extensible Application Markup Language (XAML), avoid changing the state of an ink stroke to retrieve the raw pointer data by using GetInkPoints instead.
- See Also