【发布时间】:2015-05-23 05:36:31
【问题描述】:
如何获得路径的 Y 坐标取决于 X 坐标?例如,假设我们有一条从起点 [100,50] 到终点 [200,50] 的线(路径)。我想知道当 X 坐标等于 150 时 Y 坐标的值。(这只是一个简单的例子,我的路径可以弯曲很多)。谢谢你的帮助。
我可以像这样得到路径的两个坐标:
//Count coordinates of path of lineChart
PathMeasure pm = new PathMeasure(myPath, false);
//coordinates will be here
float aCoordinates[] = {0f, 0f};
pm.getPosTan(pm.getLength() * 0.5, aCoordinates, null);
例如,这会将坐标返回到路径的中间点。 我正在寻找类似“getYCoordinate(myPath, xCoordinate)”的东西。
【问题讨论】:
标签: android path coordinates draw