InkDrawingAttributes InkDrawingAttributes InkDrawingAttributes InkDrawingAttributes Class

Definition

Provides properties associated with the drawing of an InkStroke.

public : sealed class InkDrawingAttributes : IInkDrawingAttributes, IInkDrawingAttributes2, IInkDrawingAttributes3, IInkDrawingAttributes4public sealed class InkDrawingAttributes : IInkDrawingAttributes, IInkDrawingAttributes2, IInkDrawingAttributes3, IInkDrawingAttributes4Public NotInheritable Class InkDrawingAttributes Implements IInkDrawingAttributes, IInkDrawingAttributes2, IInkDrawingAttributes3, IInkDrawingAttributes4// You can use this class in JavaScript.
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

The following example demonstrates how to set a default drawing attribute for all strokes managed by an InkManager object (inkManager).


var inkManager = new Windows.UI.Input.Inking.InkManager();
var drawingAttributes = 
     new Windows.UI.Input.Inking.InkDrawingAttributes();
// True is the Default value for fitToCurve.
drawingAttributes.fitToCurve = false;
// Set color to red (default is black).
drawingAttributes.color = 
     Windows.UI.ColorHelper.fromArgb(255, 255, 0, 0); 
inkManager.setDefaultDrawingAttributes(drawingAttributes);
// Create the InkManager instance.
Windows.UI.Input.Inking.InkManager inkManager = 
  new Windows.UI.Input.Inking.InkManager();
Windows.UI.Input.Inking.InkDrawingAttributes drawingAttributes = 
  new Windows.UI.Input.Inking.InkDrawingAttributes();
// True is the Default value for fitToCurve.
drawingAttributes.FitToCurve = false;
// Set color to red (default is black).
drawingAttributes.Color = Windows.UI.Colors.CornflowerBlue;
inkManager.SetDefaultDrawingAttributes(drawingAttributes);

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.

Remarks

InkDrawingAttributes can be set globally through the SetDefaultDrawingAttributes method of an InkManager object or an InkStrokeBuilder object. They can also be set on an individual InkStroke object through the DrawingAttributes property.

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

Constructors

InkDrawingAttributes() InkDrawingAttributes() InkDrawingAttributes() InkDrawingAttributes()

Creates a new InkDrawingAttributes object that is used to specify InkStroke attributes.

public : InkDrawingAttributes()public InkDrawingAttributes()Public Sub New()// You can use this method in JavaScript.

Examples

The following example demonstrates how to create an InkDrawingAttributes object and set a default drawing attribute for all strokes managed by an InkManager object (inkManager).


var inkManager = new Windows.UI.Input.Inking.InkManager();
var drawingAttributes = new Windows.UI.Input.Inking.InkDrawingAttributes();
drawingAttributes.fitToCurve = true;
inkManager.setDefaultDrawingAttributes(drawingAttributes);
See Also

Properties

Color Color Color Color

Gets or sets a value that indicates the color of an InkStroke.

public : Color Color { get; set; }public Color Color { get; set; }Public ReadWrite Property Color As Color// You can use this property in JavaScript.
Value
Color Color Color Color

The ink color as an ARGB value. The default is black (0, 0, 0, 0).

Examples

The following example demonstrates how to set the Color property (color) of an InkStroke (stroke) using the Windows.UI.ColorHelper.FromArgb method.


var drawingAttributes = stroke.drawingAttributes;
drawingAttributes.color = 
     Windows.UI.ColorHelper.fromArgb(255, 255, 0, 0);
stroke.drawingAttributes = drawingAttributes;

The following alternative demonstrates how to set the Color property (color) of an InkStroke (stroke) without using the Windows.UI.ColorHelper.FromArgb method.

var drawingAttributes = stroke.drawingAttributes;
var color = drawingAttributes.color;
color.a = 255;
color.r = 255;
color.g = 0;
color.b = 0;
drawingAttributes.color = color;
stroke.drawingAttributes = drawingAttributes;

For the complete example, see Ink App sample.

Remarks

The value of Color is an ARGB value. However, the value of the transparency component (A, or alpha channel) is ignored and the InkStroke is rendered at full opacity.

The value of the transparency component is not discarded. It is stored with all other stroke data in the Ink Serialized Format (ISF) file when the InkStroke is saved.

See Also

DrawAsHighlighter DrawAsHighlighter DrawAsHighlighter DrawAsHighlighter

Gets or sets a value that indicates whether the InkStroke is rendered as a highlighter overlay. The stroke is typically set to a bright color, such as yellow.

public : PlatForm::Boolean DrawAsHighlighter { get; set; }public bool DrawAsHighlighter { get; set; }Public ReadWrite Property DrawAsHighlighter As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

true to render the stroke as a highlighter; otherwise false. The default value is false.

See Also

FitToCurve FitToCurve FitToCurve FitToCurve

Gets or sets a value that indicates whether a Bezier curve or a collection of straight line segments is used to draw an InkStroke.

public : PlatForm::Boolean FitToCurve { get; set; }public bool FitToCurve { get; set; }Public ReadWrite Property FitToCurve As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

true if a Bezier curve is used; otherwise false. The default value is true.

Examples

The following example demonstrates how to set the FitToCurve attribute for all strokes managed by this InkManager object (inkManager) that are created after the SetDefaultDrawingAttributes method call.


var inkManager = new Windows.UI.Input.Inking.InkManager();
var drawingAttributes = 
     new Windows.UI.Input.Inking.InkDrawingAttributes();
// True is the Default value for fitToCurve.
drawingAttributes.fitToCurve = false;
inkManager.setDefaultDrawingAttributes(drawingAttributes);

For the complete example, see Ink App sample.

See Also

IgnorePressure IgnorePressure IgnorePressure IgnorePressure

Gets or sets a value that indicates whether the pressure of the contact on the digitizer surface is ignored when you draw an InkStroke.

public : PlatForm::Boolean IgnorePressure { get; set; }public bool IgnorePressure { get; set; }Public ReadWrite Property IgnorePressure As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

true if pressure is ignored; otherwise false. The default value is false.

Examples

The following example demonstrates how to set the IgnorePressure attribute for all strokes managed by this InkManager object (inkManager) that are created after the SetDefaultDrawingAttributes method call.


var inkManager = new Windows.UI.Input.Inking.InkManager();
var drawingAttributes = new Windows.UI.Input.Inking.InkDrawingAttributes();
drawingAttributes.ignorePressure = true;
inkManager.setDefaultDrawingAttributes(drawingAttributes);

For the complete example, see Ink App sample.

Remarks

If IgnorePressure is set to false, the user can modify the thickness of a stroke by adjusting the amount of pressure applied to the digitizer surface while writing.

The following actions may be affected by the IgnorePressure setting.

IgnorePressureTrueFalse
CopyNo effect. Pressure data, if present, is written to the Ink Serialized Format (ISF) stream.No effect. Pressure data, if present, is written to the Ink Serialized Format (ISF) stream.
PasteDepending on the implementation, pressure data from Ink Serialized Format (ISF) stream may be ignored during rendering.Depending on the implementation, pressure data from Ink Serialized Format (ISF) stream may be applied during rendering.
SaveNo effect. Pressure data, if present, is written to the Ink Serialized Format (ISF) stream.No effect. Pressure data, if present, is written to the Ink Serialized Format (ISF) stream
LoadDepending on the implementation, pressure data from Ink Serialized Format (ISF) stream may be ignored during rendering.Depending on the implementation, pressure data from Ink Serialized Format (ISF) stream may be applied during rendering.

See Also

IgnoreTilt IgnoreTilt IgnoreTilt IgnoreTilt

Gets or sets a value that indicates whether the tilt (tiltx, tilty ) of the contact on the digitizer surface is ignored when you draw an InkStroke.

public : PlatForm::Boolean IgnoreTilt { get; set; }public bool IgnoreTilt { get; set; }Public ReadWrite Property IgnoreTilt As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

true if tilt is ignored; otherwise false. The default value is false.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

This property is typically set for pencil strokes.

Kind Kind Kind Kind

Gets the InkDrawingAttributes that describe the characteristics of a specific type of InkStroke.

public : InkDrawingAttributesKind Kind { get; }public InkDrawingAttributesKind Kind { get; }Public ReadOnly Property Kind As InkDrawingAttributesKind// You can use this property in JavaScript.
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

PencilProperties PencilProperties PencilProperties PencilProperties

Gets an instance of an InkDrawingAttributesPencilProperties object for setting properties characteristic to a pencil stroke.

public : InkDrawingAttributesPencilProperties PencilProperties { get; }public InkDrawingAttributesPencilProperties PencilProperties { get; }Public ReadOnly Property PencilProperties As InkDrawingAttributesPencilProperties// You can use this property in JavaScript.
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

PenTip PenTip PenTip PenTip

Gets or sets a value that indicates the shape of the pen tip when you draw an InkStroke.

public : PenTipShape PenTip { get; set; }public PenTipShape PenTip { get; set; }Public ReadWrite Property PenTip As PenTipShape// You can use this property in JavaScript.
Value
PenTipShape PenTipShape PenTipShape PenTipShape

The shape of the pen/stylus tip. The default is Circle.

Examples

The following example demonstrates how to set the PenTip attribute for all strokes managed by an InkManager object (inkManager).


var inkManager = new Windows.UI.Input.Inking.InkManager();
var drawingAttributes = new Windows.UI.Input.Inking.InkDrawingAttributes();
drawingAttributes.penTip = Windows.UI.Input.Inking.PenTipShape.rectangle;
inkManager.setDefaultDrawingAttributes(drawingAttributes);

For the complete example, see Ink App sample.

Remarks

Support various calligraphic effects using the PenTipShape property with PenTip.

See Also

PenTipTransform PenTipTransform PenTipTransform PenTipTransform

Gets or sets an affine transformation matrix applied to the PenTipShape used for an InkStroke.

public : Matrix3x2 PenTipTransform { get; set; }public Matrix3x2 PenTipTransform { get; set; }Public ReadWrite Property PenTipTransform As Matrix3x2// You can use this property in JavaScript.
Value
Matrix3x2 Matrix3x2 Matrix3x2 Matrix3x2

The 2-D affine transformation matrix. The default is the identity matrix.

Remarks

The M31 and M32 entries of the matrix must be zero.

This property enables various calligraphic effects, depending on PenTip and PenTipShape.

See Also

Size Size Size Size

Gets or sets a value that indicates the dimensions of the pen tip (PenTip ) used to draw an InkStroke.

public : Size Size { get; set; }public Size Size { get; set; }Public ReadWrite Property Size As Size// You can use this property in JavaScript.
Value
Size Size Size Size

The Width and Height of the pen tip in . The default value for each is 2.The shape of the PenTip can be specified as a Rectangle or a Circle.

Examples

The following example includes a function that shows how to set the Size (strokeSize) of an InkStroke (stroke).


function shapeStroke(stroke, width)
{
    var att = stroke.drawingAttributes;
    var strokeSize = att.size;
    if (strokeSize.width !== width)
    {
        strokeSize.width = strokeSize.height = width;
        att.size = strokeSize;
        stroke.drawingAttributes = att;
        return true;
    }
    else
    {
        return false;
    }
}

For the complete example, see Ink App sample.

See Also

Methods

CreateForPencil() CreateForPencil() CreateForPencil() CreateForPencil()

Creates an InkDrawingAttributes object for rendering an ink stroke with pencil characteristics.

public : static InkDrawingAttributes CreateForPencil()public static InkDrawingAttributes CreateForPencil()Public Static Function CreateForPencil() As InkDrawingAttributes// You can use this method in JavaScript.
Returns

An InkDrawingAttributes object that supports the following properties:

Setting other InkDrawingAttributes properties results in an exception.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

See Also