InkDrawingAttributesPencilProperties Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides a set of static InkDrawingAttributes properties for rendering a pencil stroke on an InkCanvas.
Get an instance of this class by calling InkDrawingAttributes.CreateForPencil and accessing InkDrawingAttributes.PencilProperties.
public ref class InkDrawingAttributesPencilProperties sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class InkDrawingAttributesPencilProperties final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class InkDrawingAttributesPencilProperties
Public NotInheritable Class InkDrawingAttributesPencilProperties
- Inheritance
- Attributes
Windows requirements
Device family |
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v3.0)
|
Examples
This example demonstrates how to render an ink stroke using pencil attributes.
First, we declare the InkCanvas in XAML.
In the code-behind, we define a SetPencilInkStyle()
function to specify the pencil stroke attributes.
- Create a specialized InkDrawingAttributes object through the CreateForPencil method.
- Set some general stroke attributes, such as Color and Size.
- If InkDrawingAttributesKind is Pencil, set the Opacity attribute.
- Call UpdateDefaultDrawingAttributes to set the InkDrawingAttributes used by the InkPresenter when rendering a new InkStroke on an InkCanvas control.
<InkCanvas x:Name="inkCanvas"/>
public sealed partial class Sample : Page
{
public SetPencilInkStyle()
{
// Initialize the pencil stroke attributes.
InkDrawingAttributes pencilAttributes = InkDrawingAttributes.CreateForPencil();
pencilAttributes.Color = Windows.UI.Colors.Red;
pencilAttributes.Size = new Windows.Foundation.Size(3, 3);
Debug.Assert(attributes.Kind == InkDrawingAttributesKind.Pencil);
pencilAttributes.PencilProperties.Opacity = 0.5f;
// Update InkPresenter with the pencil attributes.
inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(pencilAttributes);
}
}
struct MainPage : MainPageT<MainPage>
{
void SetPencilInkStyle()
{
// Initialize the pencil stroke attributes.
auto pencilAttributes{ Windows::UI::Input::Inking::InkDrawingAttributes::CreateForPencil() };
pencilAttributes.Color(Windows::UI::Colors::Red());
pencilAttributes.Size({ 3, 3 });
WINRT_ASSERT(pencilAttributes.Kind() == Windows::UI::Input::Inking::InkDrawingAttributesKind::Pencil);
pencilAttributes.PencilProperties().Opacity(.5f);
// Update the InkPresenter with the pencil attributes.
m_inkCanvas.InkPresenter().UpdateDefaultDrawingAttributes(pencilAttributes);
}
}
public sealed partial class Sample : Page
{
public SetPencilInkStyle()
{
// Initialize the pencil stroke attributes.
InkDrawingAttributes^ pencilAttributes = InkDrawingAttributes::CreateForPencil();
pencilAttributes->Color = Windows::UI::Colors::Red;
pencilAttributes->Size = Windows::Foundation::Size(3, 3);
assert(pencilAttributes->Kind == InkDrawingAttributesKind::Pencil);
pencilAttributes->PencilProperties->Opacity = 0.5f;
// Update the InkPresenter with the pencil attributes.
inkCanvas->InkPresenter->UpdateDefaultDrawingAttributes(pencilAttributes);
}
}
Remarks
By default, a pencil draws a soft-edged, textured, and semi-transparent stroke (useful for layered shading effects) with a Circle PenTip. The stroke color (darkness) is dependent on the pen pressure detected.
Properties
Opacity |
Gets or sets the level of transparency used for rendering a pencil stroke on an InkCanvas. Opacity is a static property of InkDrawingAttributes. Get an instance of this class by calling InkDrawingAttributes.CreateForPencil and accessing InkDrawingAttributes.PencilProperties. |
Applies to
See also
- InkToolbar
- InkToolbarPencilButton
- Pen and stylus interactions
- Get started: Support ink in your UWP app
- Ink analysis sample (basic) (C#)
- Ink handwriting recognition sample (C#)
- Save and load ink strokes from an Ink Serialized Format (ISF) file
- Save and load ink strokes from the clipboard
- Ink toolbar location and orientation sample (basic)
- Ink toolbar location and orientation sample (dynamic)
- Coloring book sample
- Family notes sample
- Inking sample (JavaScript)
- Simple inking sample (C#/C++)
- Complex inking sample (C++)
- Ink analysis sample