获取正在绘制线的所有点

发布于 2024-12-29 21:16:59 字数 133 浏览 4 评论 0原文

我在画布上画一条线。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

碍人泪离人颜 2025-01-05 21:16:59

假设起点为 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文