I used the link another question here I made a few changes, and it worked pretty well for me.
To understand, we can think that we just need to save a map of actions and points. We need path.moveTo (int x, int y), path.lineTo (int x, int y), path.quadTo (int x1, int y1, int x2, int y2) and path.reset () methods for the string.
Actions in this case: lineTo, moveTo, quadTo, reset, and the points are the corresponding points.
I took two arrays 1 for x and another for y. For quadTo (x1, y1, x2, y2) we need two points, for reset we do not need points, and for others we need one point (x, y).
We may think that actions are keys and {arrayX [], arrayY []} are the values ββfor the action. For actions like lineTo and moveTo the size of arrayX [] and arrayY [] is 1, and for quadTo the size is 2, and for reset the size is 0 (or we can have both arrays null), because in this case we need no points. We just need to be careful when retrieving the point values ββfrom the array corresponding to the Action key. when the action is lineTo, we just draw the path on the canvas. Thanks to Krishna
source share