API Reference › Noise › Noise.perlin2
method

Noise.perlin2

Noise.perlin2(x, y, seed) -> fixed

Samples 2D **Perlin gradient noise** at (x, y) for the given seed and returns a fixed in [-1, 1]. Instead of a random value per lattice point, Perlin places a random gradient at each corner and interpolates their dot products with the offset vectors — which gives smoother, more natural gradients than value noise, the familiar look of classic terrain and cloud fields. By construction the value is exactly 0 at every integer lattice point.

Deterministic in fixed point across platforms and runs. Scale the coordinates to set feature size, and stack octaves with Noise.fbm2 for richer detail.

Parameters

seedthe field selector

Example

program Perlin {
  entry {
    let seed = 1337
    if Noise.perlin2(fixed(0), fixed(0), seed) == 0 { print(1) }   # zero at the lattice
    let n = Noise.perlin2(fixed(10) / fixed(3), fixed(7) / fixed(3), seed)
    print(Math.floor(n * fixed(1000)))
  }
}
← All symbols