0

enter image description here

I have captured points data from bamboo slate,and converted them to Windows.UI.Input.Inking.InkStroke data.Then I put them in a InkPresenter.StrokeContainer rendered like this image above.Strokes sticked to each other,how can I seperate them? This is my code below.

private void DataDisplay()
    {
        List<InkPoint> list = new List<InkPoint>();
        List<InkStroke> strokes = new List<InkStroke>();
        InkDrawingAttributes drawingAttributes1 = new InkDrawingAttributes();
        drawingAttributes1.Color = Colors.Black;
        drawingAttributes1.Size = new Size(1, 1);
        InkStrokeBuilder builder = new InkStrokeBuilder();
        builder.SetDefaultDrawingAttributes(drawingAttributes1);
        inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes1);
        inkCanvas.InkPresenter.IsInputEnabled = true;
        foreach (var item in data.Stroke)
        {
                string[] strArray = item.Split(',');
                for (int i = 9; i <= strArray.Length - 5; i += 5)
                {
                    float x = float.Parse(strArray[i]) / 30;
                    float y = float.Parse(strArray[i + 1]) / 30;
                    float pressure = float.Parse(strArray[i + 2]) / 1000;
                    Point point = new Point(x, y);
                    InkPoint ip = new InkPoint(point, pressure);
                    list.Add(ip);
                }
                Matrix3x2 matrix3X2 = new Matrix3x2(1, 0, 0, 1, 0, 0);
                InkStroke newStroke = builder.CreateStrokeFromInkPoints(list, matrix3X2);
                strokes.Add(newStroke);
            }
            inkCanvas.InkPresenter.StrokeContainer.AddStroke(strokes);
}
  • For adding more ink strokes to InkStrokeContainer, you need to use [InkStrokeContainer.AddStrokes](https://learn.microsoft.com/en-us/uwp/api/windows.ui.input.inking.inkstrokecontainer.addstrokes?view=winrt-19041) method instead of StrokeContainer.AddStroke(). Besides, I don’t understand well about what Render InkStrokes in InkCanvas Seperately means. Could you please tell me in detail what your expected behavior is or what problem you are facing? – dear_vv Apr 06 '21 at 08:52
  • Thanks for your comment.I also tried InkStrokeContainer.AddStrokes method,but nothing changed.As you can see in the image I uploaded,it seems that someone writes this in only one stroke.I'd like to seperate this stroke by letters. – wuren1993 Apr 09 '21 at 03:47
  • I’m not clear about `string[] strArray = item.Split(',')`, item is a InkStroke object, could you please tell me why you operate it as a string type? In your scenario, you have used the same Matrix3x2 value for every InkStroke object, which causes these strokes will get the same transform(such as translate or rotate), so these strokes can’t be separated. It is difficult to achieve this effect you expected, because you need to find suitable Matrix object for every stroke and adjust it according to the specified situation of each stroke. – dear_vv Apr 13 '21 at 09:35

0 Answers0