缩放连接线
我有某种由垂直线、水平线和对角线组成的形状。我有每条线的开始 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你希望它扩展到什么程度?您可以相对于第一个点、中心或其他任意位置进行缩放。通常,您减去偏移量(例如输入中的第一个点),乘以比例因子,然后加回偏移量。
计算机图形学中更系统的方法是使用变换矩阵...尽管对于你的情况来说,这可能有点过分了。
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.