evolvePath()
属于@remotion/paths
包。
将SVG路径从不可见状态动画到完全长度。该函数接受两个参数:
-
progress
是朝向完全演变的进度,其中0
表示路径不可见,1
表示路径完全绘制出来。note传入大于 1 的值将导致路径的起点逐渐消失。传入小于 0 的值将导致路径从末尾开始绘制。
-
path
必须是有效的SVG路径。
返回值将是一个包含strokeDasharray
和strokeDashoffset
值的对象,这些值应该传递给<path>
元素。
tsx
import {evolvePath } from "@remotion/paths";constpath = "M 0 0 L 100 0";constevolution =evolvePath (0.5,path );console .log (evolution ); // { strokeDasharray: '100 100', strokeDashoffset: 50 }constelement = (<path d ={path }strokeDasharray ={evolution .strokeDasharray }strokeDashoffset ={evolution .strokeDashoffset }/>);
tsx
import {evolvePath } from "@remotion/paths";constpath = "M 0 0 L 100 0";constevolution =evolvePath (0.5,path );console .log (evolution ); // { strokeDasharray: '100 100', strokeDashoffset: 50 }constelement = (<path d ={path }strokeDasharray ={evolution .strokeDasharray }strokeDashoffset ={evolution .strokeDashoffset }/>);