缩放连接线

发布于 2024-09-02 12:00:28 字数 213 浏览 3 评论 0原文

我有某种由垂直线、水平线和对角线组成的形状。我有每条线的开始 X,Y 和结束 X,Y (这是我的输入 - 只需定义一条线的 2 个点),我想让整个形状可缩放(只需更改比例变量的值),这样我仍然可以保持线条和比例的正确连接。只是为了更好地理解我的意思:就好像我在矢量编辑器中有相同的行一样。

这可以通过算法实现吗?如果没有这样的算法,请给我另一个可能的解决方案吗?

预先非常感谢您!

I have some kind of a shape consisting of vertical, horizontal and diagonal lines. I have starting X,Y and ending X,Y (this is my input - just 2 points defining a line) of each line and I would like to make the whole shape scalable (just by changing the value of a scale ratio variable), so that I can still preserve the proper connection of the lines and the proportions as well. Just for getting a better idea of what I mean: it'd be as if I had the same lines in a vector editor.

Would that be possible with an algorithm, and could you please, give me another possible solution if there is no such algorithm ?

Thank you very much in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

三人与歌 2024-09-09 12:00:28

你希望它扩展到什么程度?您可以相对于第一个点、中心或其他任意位置进行缩放。通常,您减去偏移量(例如输入中的第一个点),乘以比例因子,然后加回偏移量。

计算机图形学中更系统的方法是使用变换矩阵...尽管对于你的情况来说,这可能有点过分了。

what point do you want it to scale about? You could scale relative to the first point, the center, or some other arbitrary location. Typically, you subtract out an offset (for instance the first point in your input), multiply by a scale factor, and then add back the offset.

A more systematic approach in computer graphics would be to use a transformation matrix... although thats probably overkill in your case.

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