获取正在绘制线的所有点
我在画布上画一条线。
canvas.drawLine(p1.x, p1.y, p2.x, p2.y, paint);
我想获取 Point1 和 Point 2 之间绘制线条的所有点。
I am drawing a line on canvas like.
canvas.drawLine(p1.x, p1.y, p2.x, p2.y, paint);
and I want to get all the points in between Point1 and Point 2 where the line in being drawn.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设起点为 p1,终点为 p2,则
Delta(变化)= p1-p2
dx(x 变化)=p1.x-p2.x
dy(y 变化)=p1.y-p2.y
要找到直线上的点 P,请使用以下公式。
求 L 的 Px 和 Py 从 0-1 变化
Px = p1.x + L * dx
PY = p1.Y + L * dy
Suppose the Start point is p1 and the End Point is p2 then,
Delta (change) = p1-p2
dx (change in x) =p1.x-p2.x
dy (change in y) =p1.y-p2.y
To find point P on the line use the below formula.
Find Px and Py for L varies from 0-1
Px = p1.x + L * dx
PY = p1.Y + L * dy