Harley-xk / MaLiang

iOS painting and drawing library based on Metal. 神笔马良有一支神笔(基于 Metal 的涂鸦绘图库)
MIT License
1.47k stars 209 forks source link

is there a way to get the draw strokes points ? #120

Closed X901 closed 3 years ago

X901 commented 3 years ago

Hi , when using PencilKit you can get strokes points , and you can redraw the points is there something like that I can do with the library ?

Harley-xk commented 3 years ago

Yes, All points are stored in the "data" property of Canvas

发自我的iPhone

在 2021年10月22日,07:40,Basil Baragabah @.***> 写道:

 Hi , when using PencilKit you can get strokes points , and you can redraw the points is there something like that I can do with the library ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

X901 commented 3 years ago

Yes, All points are stored in the "data" property of Canvas 发自我的iPhone

I did check .data but I cannot access points

to give you Idea what I want to do is I need to reach points so I can match between what it was drew and what user drawing

Harley-xk commented 3 years ago

@X901 There's a property called elements on the class CanvasData, whitch is the type of data property on Canvas. All elements are follow the CanvasElement protocol. Includes lines(LineStrip) you draw on the canvas. A LineStrip is constructed by several MLLines, a MLLine is a strait line contains two points for begin and end, and other properties such as color, size etc.

Harley-xk commented 3 years ago

@X901 There are two builtin tools called DataExporter and DataImporter. You can export all points and other elements data into a JSON file with DataExporter and then import them to another canvas on even other devices later by DataImporter.

X901 commented 3 years ago

Thank you ,but it looks like I will need sometimes to understand the data.