Skip to main content

noise2D()

Part of the @remotion/noise package.

创建 2D 噪声。

API

该函数接受三个参数:

seed

传入任何 字符串数字。如果种子相同,则对于相同的 xy 值将获得相同的结果。更改种子以获得不同的结果,适用于您的 xy 值。

x

数字

第一个维度值。

y

数字

第二个维度值。

返回值

一个介于 -11 之间的值,随着您的 xy 值的变化而摆动。

示例

tsx
import { noise2D } from "@remotion/noise";
 
const x = 32;
const y = 40;
console.log(noise2D("my-seed", x, y)); // a number in the interval [-1, 1] which corresponds to (x, y) coord.
tsx
import { noise2D } from "@remotion/noise";
 
const x = 32;
const y = 40;
console.log(noise2D("my-seed", x, y)); // a number in the interval [-1, 1] which corresponds to (x, y) coord.

Credits

使用了 simplex-noise 依赖项

另请参阅