src/perlin/private/types

Types

AnyPoint[T] = Point4D[T] | Point3D[T] | Point2D[T]
Noise = object
A noise instance
  • perm is a set of random numbers used to generate the results
  • octaves allows you to combine multiple layers of noise into a single result
  • persistence is how much impact each successive octave has on the result
NoiseType {.pure.} = enum
  perlin, simplex
The types of noise available
Point[S; T] = array[S, T]
A point of N dimensions with a specific precision
Point2D[T] = Point[2, T]
A helper definition for a 3d point
Point3D[T] = Point[3, T]
A helper definition for a 3d point
Point4D[T] = Point[4, T]
A helper definition for a 4d point

Procs

proc buildPermutations(seed: uint32): array[0 .. 511, int] {....raises: [],
    tags: [], forbids: [].}
Returns a hash lookup table. It is all the numbers from 0 to 255 (inclusive) in a randomly sorted array, twice over
proc i(point: AnyPoint): auto {.inline.}
proc j(point: AnyPoint): auto {.inline.}
proc k(point: Point3D): auto {.inline.}
proc newNoise(): Noise {....raises: [], tags: [], forbids: [].}
Creates a new noise instance with a random seed
proc newNoise(octaves: int; persistence: float): Noise {....raises: [], tags: [],
    forbids: [].}
Creates a new noise instance with a random seed
  • octaves allows you to combine multiple layers of noise into a single result
  • persistence is how much impact each successive octave has on the result
proc newNoise(seed: uint32; octaves: int = 1; persistence: float = 0.5): Noise {.
    ...raises: [], tags: [], forbids: [].}
Creates a new noise instance with the given seed
  • octaves allows you to combine multiple layers of noise into a single result
  • persistence is how much impact each successive octave has on the result
proc octaves(noise: Noise): auto {.inline, ...raises: [], tags: [], forbids: [].}
proc persistence(noise: Noise): auto {.inline, ...raises: [], tags: [], forbids: [].}
proc w(point: Point4D): auto {.inline.}
proc x(point: AnyPoint): auto {.inline.}
proc y(point: AnyPoint): auto {.inline.}
proc z(point: Point3D | Point4D): auto {.inline.}