To start off with…
When you collect Strokes in an InkCanvas, the appearance of each Stroke is controlled by two things:
1) The sampling points of the Stroke (or spine)
2) The DrawingAttributes of the Stroke
A good way to think of this is that at each sampling point, there is a shape around the point:
Each shape is connected:
If the ink is being collected with a Stylus, and there is pressure information present, we scale the shape at each sampling point based on the pressure:
And then we fill the outer contour and render the stroke.
To control the shape for each sampling point (and ultimately how the Stroke appears), we have a class named DrawingAttributes. You can find it as properties on two objects:
1) Stroke.DrawingAttributes – Controls what each Stroke looks like
2) InkCanvas.DefaultDrawingAttributes – Controls the DrawingAttributes that each new Stroke collected by the InkCanvas will have. Since DrawingAttributes is a reference type, we clone the InkCanvas.DefaultDrawingAttributes for each new Stroke. If we didn’t, all Strokes would change appearance when any Stroke.DrawingAttributes instance was altered.
Here are the properties that DrawingAttributes has, and what each controls:
1) Color – The color of the Stroke. We use this to create a SolidColorBrush to fill the Stroke with when we render it to the MIL (Avalon Media Integration Layer)
2) IgnorePressure – A boolean that instructs us to ignore pressure if present. If this is set to false, we will scale the shape around each sampling point based on the pressure collected at the sampling point.
3) StylusTip – The shape of the sampling points. We support Rectangle and Ellipse.
4) StylusTipTransform – A Matrix that allows you to rotate / shear / scale the shape of the sampling points.
5) Height – The height of the shape around the sampling points.
6) Width – The width of the shape around the sampling points.
7) FitToCurve – Set this to true if you would like us to apply Bezier smoothing to the Stroke.
8) IsHighlighter – A boolean that instructs us to treat this Stroke in a special way by applying a transparency that doesn’t blend with other IsHighlighter Strokes of the same color. In our COM \ WinForms platform, which rendered via GDI \ GDI+, this was controlled by the DrawingAttributes.RasterOperation property, but the MIL does not support GDI raster ops.
Understanding InkCanvas, EditingModes and DrawingAttributes enables you to do a lot with our platform. In upcoming blogs, I plan on talking about:
1) The difference between our Avalon and COM \ WinForms object model’s and why we made changes
2) How to do recognition of your Avalon Strokes
3) How to do custom rendering of your Avalon Strokes
And more. Stay tuned…