Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android path to array - read the points on a path?

Tags:

android

path

Is there a way to read the points created when drawing a path? It seems silly to me that a path cannot be readable.

Or is it just better to manually write the current finger position to an array?

thanks

like image 688
Matt Avatar asked Jul 05 '10 15:07

Matt


2 Answers

You can read as many points as you want from any path. Example how to read coordinates from the middle of path:

    PathMeasure pm = new PathMeasure(myPath, false);
    //coordinates will be here
    float aCoordinates[] = {0f, 0f};

    //get coordinates of the middle point
    pm.getPosTan(pm.getLength() * 0.5f, aCoordinates, null);

You can pass any distance from the path start to get point coordinates.

like image 200
Eduard Avatar answered Oct 20 '22 02:10

Eduard


As far as I know, I think that you can't get previously added points, but you can extend Path class and create your own, override add methods, and then store that points in an array or a list or whatever you prefer.

like image 35
Rabas Avatar answered Oct 20 '22 02:10

Rabas