normalizePath()
属于@remotion/paths
包。
从路径中移除所有相对坐标,并将它们转换为绝对坐标。
如果路径有效,则返回一个字符串:
tsx
import {normalizePath } from "@remotion/paths";constnormalizedPath =normalizePath ("M 50 50 l 100 0");console .log (normalizedPath ); // "M 50 50 L 150 50"
tsx
import {normalizePath } from "@remotion/paths";constnormalizedPath =normalizePath ("M 50 50 l 100 0");console .log (normalizedPath ); // "M 50 50 L 150 50"
如果路径无效,则该函数将抛出错误:
tsx
normalizePath ("remotion"); // Error: Malformed path data: ...
tsx
normalizePath ("remotion"); // Error: Malformed path data: ...
Credits
源代码主要来自于svg-path-reverse。