locked
How to use custom shapes for brushes with inkManager?

    Question

  • How would you use custome brush shapes and effects (water paint, oil paint, smudge, charcoal) like in freshPaint with C# and the inkManager? Is there a way to use custom strokes, shapes etc? Or do you have to use c++/d2d?
    • Edited by SW_Andy Thursday, July 3, 2014 1:35 PM
    Thursday, July 3, 2014 1:31 PM

Answers

  • The InkManager doesn't do any rendering. It just supplies the strokes and the app renders them however it likes. For art-like brushes you'll probably be best off with an ImageBrush based on your art texture and use can use the Pressure, Tilt, etc. properties from the InkStrokeRenderingSegment to determine how to draw the actual stroke segment. See Quickstart: Image and ImageBrush

    The Input: Simplified ink sample  provides a basic demonstration. Its XamlInkRenderer class takes the render segments and creates a Windows.UI.Xaml.Media.PathFigure which follows the stroke's path. You can replace the path.Stroke's SolidColorBrush with your custom ImageBrush.

    --Rob

    • Marked as answer by SW_Andy Friday, July 11, 2014 11:14 AM
    Thursday, July 10, 2014 5:40 PM
    Owner

All replies

  • You can likely do any custom stroke you want in C#, but you need to develop the brush yourself.  It's just a matter of putting some graphics on the screen under the mouse.  I don't have source code for this. 


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, July 3, 2014 7:25 PM
    Moderator
  • Yes I got the idea and mechanics behind that... but I have no clue where to start, because (as often) many examples I find are not compatible with .NET for Windows Store. They're mostly WPF.

    So there's a hatchBrush and Texturebrush but they don't exist for WinRT.

    What would be the correct part of the API to jump into?
    PenTipShape? But how? There're only two presets, named "circle" and "rectangle". Dosen't seem you can expand or modifiy that.

    Or would the stroke itself be the right way? Or the pathFigure? The

    Or am I completley wrong here and you can't do it with C#? Maybe then with SharpDX or going right away woth C++/D2D1. But same question here... where to start (don't Need working source code... but a meaningful hint in the right direction).

    Thursday, July 10, 2014 2:35 PM
  • The InkManager doesn't do any rendering. It just supplies the strokes and the app renders them however it likes. For art-like brushes you'll probably be best off with an ImageBrush based on your art texture and use can use the Pressure, Tilt, etc. properties from the InkStrokeRenderingSegment to determine how to draw the actual stroke segment. See Quickstart: Image and ImageBrush

    The Input: Simplified ink sample  provides a basic demonstration. Its XamlInkRenderer class takes the render segments and creates a Windows.UI.Xaml.Media.PathFigure which follows the stroke's path. You can replace the path.Stroke's SolidColorBrush with your custom ImageBrush.

    --Rob

    • Marked as answer by SW_Andy Friday, July 11, 2014 11:14 AM
    Thursday, July 10, 2014 5:40 PM
    Owner
  • Hi Rob,

    thanks - that's good news. Sounds great. I'll try in that direction then.

    Thanks,
    Andy


    • Edited by SW_Andy Friday, July 11, 2014 11:15 AM
    Friday, July 11, 2014 11:14 AM