我应该使用什么算法来平滑地缩放图形或地图?
我有一个由函数生成的图表,它会根据函数的值自动放大和缩小。我已经有了绘图工具,可以以高分辨率显示任何 x、y、宽度、高度。
我试着捕捉到正确的位置:
x = target_x
y = target_y
width = target_width
height = target_height
但它太跳跃了。很难判断哪个部分被放大/缩小。
我也尝试过这样做:
orig_x = x //ditto for y, width, height, etc
for i=1 to 10
x = i/10*new_x + i/10*orig_x
wait 25ms
比较顺利,但第一步仍然太跳跃。如果 orig_x 为 10,new_x 为 100 万,则第一次跳跃太大,接近 1,000,000%。然而,最后一次跳跃仅为 10%。几何级数更好,但如果我必须在变焦过程中切换方向,那么步骤会很跳跃。
使用什么效果最好?
I have a graph, generated by a function, and it zooms itself in and out automatically, depending on the value of the function. I already have the graphing tools and I can display any x,y,width,height at high resolution.
I tried just snapping to the right spot:
x = target_x
y = target_y
width = target_width
height = target_height
But it's too jumpy. It's hard to tell what part was zoomed in/out.
I also tried doing this:
orig_x = x //ditto for y, width, height, etc
for i=1 to 10
x = i/10*new_x + i/10*orig_x
wait 25ms
It's smoother but the first step is still too jumpy. If orig_x is 10 and new_x is 1 million then the first jump is too big, near 1,000,000%. Last jump is just 10%, however. A geometric progression is even better but if I have to switch directions mid-zoom the steps are jumpy.
What would be the best effect to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您希望为每个步骤缩放/移动最后一个窗口的固定百分比。这意味着您的变焦将呈指数曲线,并且您的移动将与变焦相关联。像下面这样的东西应该是一个改进:
You want to zoom/shift a fixed percentage of the last window for each step. That means your zoom will be an exponential curve, and your shift will be tied to your zoom. Something like the following should be an improvement:
我可以尝试
I may try