Skip to main content

interpolatePath()

属于@remotion/paths包。

在两个SVG路径之间进行插值。该函数接受三个参数:

  • value,一个数字。
    • 如果是0,则返回第一个路径。
    • 如果是1,则返回第二个路径。
    • 如果在范围之间或范围之外,则进行路径插值。
  • firstPath,必须是有效的SVG路径。
  • secondPath,必须是有效的SVG路径。
tsx
import { interpolatePath } from "@remotion/paths";
 
const interpolated = interpolatePath(0.5, "M 0 0 L 100 0", "M 100 0 L 0 0");
console.log(interpolated); // "M 50 0 L 50 0"
tsx
import { interpolatePath } from "@remotion/paths";
 
const interpolated = interpolatePath(0.5, "M 0 0 L 100 0", "M 100 0 L 0 0");
console.log(interpolated); // "M 50 0 L 50 0"

Credits

源代码主要来自d3-interpolate-path

See also