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

前端 未结 3 1225
小鲜肉
小鲜肉 2020-12-14 03:08

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 curren

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 03:37

    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.

提交回复
热议问题