缩放插值
🌐 Zoom interpolation
一个插值器,用于在二维平面的两个视图之间平滑缩放,基于 Jarke J. van Wijk 和 Wim A.A. Nuij 的《平滑高效的缩放和平移》(“Smooth and efficient zooming and panning”)。
🌐 An interpolator for zooming smoothly between two views of a two-dimensional plane based on “Smooth and efficient zooming and panning” by Jarke J. van Wijk and Wim A.A. Nuij.
interpolateZoom(a, b)
js
d3.interpolateZoom([30, 30, 40], [135, 85, 60])(0.5) // [72, 52, 126.04761005270991]示例 · 来源 · 返回两个视图 a 和 b 之间的插值器。每个视图定义为一个包含三个数字的数组:cx、cy 和 width。前两个坐标 cx、cy 表示视口的中心;最后一个坐标 width 表示视口的大小。
返回的插值器公开了一个 interpolate.duration 属性,该属性以毫秒为单位编码推荐的过渡持续时间。这个持续时间基于通过 xy 空间的曲线路径长度。如果你想要更慢或更快的过渡,可以将其乘以一个任意的缩放因子(如原始论文中所述 V )。
interpolateZoom.rho(rho)
js
d3.interpolateZoom.rho(0.5)([30, 30, 40], [135, 85, 60])(0.5) // [72, 52, 51.09549882328188]来源 · 给定一个缩放插值器,返回使用指定曲率rho的新缩放插值器。当rho接近0时,插值器几乎是线性的。默认曲率为sqrt(2)。