Share via


InkStrokeRenderingSegment 类

定义

完整墨迹笔划的单个段。

单个段由一个起点、一个终点和两个贝塞尔控制点组成。 但是,对于构成笔划的一系列段,上一段的最后一点是当前段的第一个点。 这意味着只需要每个段的终点来表示完整的笔划。

每个笔划都是 InkStrokeRenderingSegment 对象的向量,第一个段由单个起点标识,其余所有段由一个终点和两个 Bezier 控制点标识。

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
继承
Object Platform::Object IInspectable InkStrokeRenderingSegment
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

以下示例中的 函数演示了如何为墨迹笔划的每个段派生三次贝塞尔曲线 (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;
}

注解

如果希望使用三次贝塞尔曲线呈现墨迹笔划,请将 DrawingAttributesFitToCurve 属性设置为 true。 否则,使用直线段呈现笔划。

属性

BezierControlPoint1

获取贝塞尔曲线的第一个控制点。

BezierControlPoint2

获取贝塞尔曲线的第二个控制点。

Position

获取段的终点。

Pressure

获取数字化器表面接触的压力。

TiltX

获取触点沿 x 轴的倾斜度。

TiltY

获取触点沿 y 轴的倾斜度。

Twist

获取沿旋转轴的接触点的扭曲。

适用于

另请参阅