Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

InkStrokeRenderingSegment class

Applies to Windows only

A single segment of a complete ink stroke.

A single segment consists of a starting point, an ending point, and two Bezier control points. However, for a series of segments that make up a stroke, the last point of the previous segment is the first point of the current segment. This means that only the ending point for each segment is required to represent a complete stroke.

Each stroke is a vector of InkStrokeRenderingSegment objects with the first segment identified by a single starting point and all remaining segments identified by an ending point and two Bezier control points.

Syntax


var inkStrokeRenderingSegment = Windows.UI.Input.Ink.InkStroke.GetRenderingSegments();

Attributes

[DualApiPartition()]
[MarshalingBehavior(None)]
[Version(0x06020000)]

Members

The InkStrokeRenderingSegment class has these types of members:

Methods

The InkStrokeRenderingSegment class inherits methods from the Object class (C#/VB/C++).

Properties

The InkStrokeRenderingSegment class has these properties.

PropertyAccess typeDescription

BezierControlPoint1

Read-onlyGets the first control point for the Bézier curve.

BezierControlPoint2

Read-onlyGets the second control point for the Bézier curve.

Position

Read-onlyGets the end point of the segment.

Pressure

Read-onlyGets the pressure of the contact on the digitizer surface.

TiltX

Read-onlyGets the tilt of the contact along the x axis.

TiltY

Read-onlyGets the tilt of the contact along the y axis.

Twist

Read-onlyGets the twist of the contact along the rotational axis.

 

Remarks

Set the FitToCurve property of DrawingAttributes to true if you want an ink stroke to be rendered with cubic Bezier curves. Otherwise, the stroke is rendered with straight line segments.

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).

Examples

The function in the following example demonstrates how a cubic Bezier curve can be derived for each segment of an ink stroke (stroke) by using the bezierCurveTo method. Each curve is then rendered through the 2-D context of the canvas (ctx).



// Render all strokes using bezier curves instead of line segments.
function renderAllStrokes()
{
    statusMessage.innerText += "Render strokes as bezier curves."

    // Clear the drawing surface of existing strokes.
    inkContext.clearRect(0, 0, inkCanvas.width, inkCanvas.height);

    // Enumerate through each stroke.
    inkManager.getStrokes().forEach(
        function (stroke)
        {
            inkContext.beginPath();
            inkContext.lineWidth = strokeWidth; 
            inkContext.strokeStyle = strokeColor; 

            // Enumerate through each line segment of the stroke.
            var first = true;
            var x = stroke.getRenderingSegments().length;
            stroke.getRenderingSegments().forEach(
                function (segment)
                {
                    // Move to the starting 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();
        }
    );
}

For the complete example, see Ink App sample.

Requirements

Minimum supported client

Windows 8 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

Minimum supported phone

None supported

Namespace

Windows.UI.Input.Inking
Windows::UI::Input::Inking [C++]

Metadata

Windows.winmd

See also

Windows.UI.Input.Inking Classes
bezierCurveTo
Responding to pen and stylus input
Ink App sample

 

 

Show:
© 2014 Microsoft