Udostępnij za pośrednictwem


InkStrokeRenderingSegment Class

Definition

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.

public ref class InkStrokeRenderingSegment sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class InkStrokeRenderingSegment final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class InkStrokeRenderingSegment
Public NotInheritable Class InkStrokeRenderingSegment
Inheritance
Object Platform::Object IInspectable InkStrokeRenderingSegment
Attributes

Windows requirements

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

Examples

The function in the following example demonstrates how a cubic Bezier curve can be derived for each segment of an ink stroke (stroke).

public static Windows.UI.Xaml.Shapes.Path CreateBezierPath(Windows.UI.Input.Inking.InkStroke stroke)
{
    // Create Bezier geometries using information provided by the stroke's segments
    var figure = new Windows.UI.Xaml.Media.PathFigure();
    var segments = stroke.GetRenderingSegments().GetEnumerator();
    segments.MoveNext();
    // First segment is degenerate and corresponds to initial position
    figure.StartPoint = segments.Current.Position;
    // Now loop through all remaining segments
    while (segments.MoveNext())
    {
        var bs = new Windows.UI.Xaml.Media.BezierSegment();
        bs.Point1 = segments.Current.BezierControlPoint1;
        bs.Point2 = segments.Current.BezierControlPoint2;
        bs.Point3 = segments.Current.Position;
        figure.Segments.Add(bs);
    }

    // Create and initialize the data structures necessary to render the figure
    var geometry = new Windows.UI.Xaml.Media.PathGeometry();
    geometry.Figures.Add(figure);
    var path = new Windows.UI.Xaml.Shapes.Path();
    path.Data = geometry;

    // Set the stroke's graphical properties, which are controlled by the Path object
    path.Stroke = new Windows.UI.Xaml.Media.SolidColorBrush(stroke.DrawingAttributes.Color);
    path.StrokeThickness = stroke.DrawingAttributes.Size.Width;
    path.StrokeLineJoin = Windows.UI.Xaml.Media.PenLineJoin.Round;
    path.StrokeStartLineCap = Windows.UI.Xaml.Media.PenLineCap.Round;

    return path;
}

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.

Properties

BezierControlPoint1

Gets the first control point for the Bézier curve.

BezierControlPoint2

Gets the second control point for the Bézier curve.

Position

Gets the end point of the segment.

Pressure

Gets the pressure of the contact on the digitizer surface.

TiltX

Gets the tilt of the contact along the x axis.

TiltY

Gets the tilt of the contact along the y axis.

Twist

Gets the twist of the contact along the rotational axis.

Applies to

See also