/SkiaInk

A C# Digital Ink Library for Skia

Primary LanguageC#MIT LicenseMIT

SkiaInk ✏️

〰️ A C# Digital Ink Library for Skia 〰️

About

SkiaInk is meant to be a lightweight and user-friendly library for creating, rendering, and manipulating digital ink. The API is inspired by Windows.UI.Input.Inking and Wacom Will SDK.

Roadmap

V0.1 - Rendering Digital Ink

  • Basic API
  • Vector Brush
  • Geometry pipeline

V0.2 - Creating Digital Ink

  • Velocity prediction (to reduce latency)
  • Path smoothing input

V0.3 - Manipulating Digital Ink

  • Partial Eraser
  • Hit testing

Future

  • Ink playback animation
  • Raster Brush
  • Default ink types such as pencil, highlighter, pen, calligraphy, etc.
  • Download as nuget package

Geometry Pipeline

Ink Pipeline

For now focusing on vector brush pipeline. Future plans for raster ink will have differing pipeline

Details

Path Smoothing

Use double exponential smoothing for user input. Will have the ability to turn off.

Spline Interpolation

Spline production/interpolation are combined as SkiaInk uses xsplines. An xspline with shape = -1, which is what SkiaInk uses for inkstrokes, is very similar to a Catmull-Rom curve.

XSplines are outlined in this paper: XSplines: A Spline Model Designed for the End User

Implementation of algorithm is ported from R source code: xspline.c

Brush Applier

Places the chosen brush on each point of the xspline line according to pressure. Interpolate the shape of the brush when applying to interpolated points

Interpolation algorithm: SkiaSharp.Extended source? Drawn inspiration from vwline package.

Convex Hull Chain

Applies a modified convex hull algorithm (see: StackOverflow) to every two adjacent brushes in a chain

Using Ouellet Convex Hull for base convex hull agorithm. The github repo. Specifically using their Avl3 algorithm.

Polyline Clipper

Performs a union of all the convex hulls to output the ink stroke outline in polyline form.

Either use the C# implementation of Clipper or use SkiaSharp paths

Polyline Simplifier

Simplify the number of points along the outline using the Ramer-Douglas-Peucker algorithm

Maybe use this implementation: https://github.com/BobLd/RamerDouglasPeuckerNetV2