src/perlin/private/common

Shared methods for generating noise

Types

Point = Point3D[float] | Point3D[int] | Point2D[float] | Point2D[int]
A 2d or 3d point with any kind of precision
Point2D[U] = tuple[x, y: U]
A helper definition for a 3d point
Point3D[U] = tuple[x, y, z: U]
A helper definition for a 3d point
PointND[U] = Point3D[U] | Point2D[U]
a point of N dimensions with a specific precision

Procs

proc buildPermutations(seed: uint32): array[0 .. 511, int] {....raises: [],
    tags: [].}
Returns a hash lookup table. It is all the numbers from 0 to 255 (inclusive) in a randomly sorted array, twice over
proc grad(hash: int; x, y, z: float): float {.inline, ...raises: [], tags: [].}
Calculate the dot product of a randomly selected gradient vector and the 8 location vectors

Templates

template map(point: Point; apply: untyped): untyped
Applies a callback to all the values in a point
template mapIt(point: Point; kind: typedesc; apply: untyped): untyped
Applies a callback to all the values in a point