getTangentAtLength()
属于 @remotion/paths 软件包的一部分.
🌐 Part of the @remotion/paths package.
获取位于 SVG 路径上的一个点的切线值 x 和 y。第一个参数是 SVG 路径,第二个参数是应采样该点的长度。它必须介于 0 和 getLength() 的返回值之间。
🌐 Gets tangent values x and y of a point which is on an SVG path. The first argument is an SVG path, the second one is the length at which the point should be sampled. It must be between 0 and the return value of getLength().
如果路径有效,则返回一个点:
🌐 Returns a point if the path is valid:
import { getTangentAtLength } from "@remotion/paths";
const tangent = getTangentAtLength ("M 50 50 L 150 50", 50);
console .log (tangent ); // { x: 1, y: 0}如果路径无效,该函数将抛出异常:
🌐 The function will throw if the path is invalid:
getTangentAtLength ("remotion", 50); // Error: Malformed path data: ...鸣谢
🌐 Credits
源代码主要来源于 svg-path-properties。
🌐 Source code stems mostly from svg-path-properties.
另请参阅
🌐 See also