Isotope.Noise (Isotope v0.1.2-rc) View Source

Provide functions to create and work with different types of noises.

Link to this section Summary

Types

A coordinate {x, y} in a cartesian plane.

A reference to the noise generator. This is needed for most of the library functions.

A noise map, represented by a list containing lists of floats (the noise values).

Options available when initializing the noise.

2-element tuple containg x and y values as floats.

3-element tuple containg x, y and z values as floats.

A tuple containing width and height

Functions

Returns a 2D noise map from start_point to end_point

Returns the 2D or 3D noise value depending on axes. If axes is a 2-float tuple, it will return the 2D noise value for the point. If axes is a 3-float tuple, it will return the 3D noise value for the point.

Returns a new noise reference using the default options.

Returns a new noise reference using the provided options.

Generates a 2D noise map of size and returns it.

Link to this section Types

Specs

coord() :: {integer(), integer()}

A coordinate {x, y} in a cartesian plane.

Specs

noise_ref() :: reference()

A reference to the noise generator. This is needed for most of the library functions.

Specs

noisemap() :: [[float()]]

A noise map, represented by a list containing lists of floats (the noise values).

Specs

options() :: Isotope.Options.t()

Options available when initializing the noise.

Specs

point2d() :: {float(), float()}

2-element tuple containg x and y values as floats.

Specs

point3d() :: {float(), float(), float()}

3-element tuple containg x, y and z values as floats.

Specs

size() :: {non_neg_integer(), non_neg_integer()}

A tuple containing width and height

Link to this section Functions

Link to this function

chunk(noise, start_point, end_point)

View Source

Specs

chunk(noise_ref(), coord(), coord()) :: noisemap()

Returns a 2D noise map from start_point to end_point

iex> {:ok, noise} = Isotope.Noise.new(%Isotope.Options{seed: 100})
iex> Isotope.Noise.chunk(noise, {0, 0}, {100, 100})

Specs

get_noise(noise_ref(), point2d() | point3d()) :: float()

Returns the 2D or 3D noise value depending on axes. If axes is a 2-float tuple, it will return the 2D noise value for the point. If axes is a 3-float tuple, it will return the 3D noise value for the point.

iex> {:ok, noise} = Isotope.Noise.new()
iex> Isotope.Noise.get_noise(noise, {10.0, 10.0})
-0.6350845098495483

iex> {:ok, noise} = Isotope.Noise.new()
iex> Isotope.Noise.get_noise(noise, {10.0, 10.0, 10.0})
-0.1322503685951233

Returns a new noise reference using the default options.

iex> {:ok, _ref} = Isotope.Noise.new()

Specs

new(options()) :: {:ok, noise_ref()} | {:error, :unsupported_noise}

Returns a new noise reference using the provided options.

iex> {:ok, _ref} = Isotope.Noise.new(%Isotope.Options{seed: 100})

iex> {:error, :unsupported_noise} = Isotope.Noise.new(%Isotope.Options{noise_type: :foobar})

Specs

noise_map(reference(), size()) :: noisemap()

Generates a 2D noise map of size and returns it.

iex> {:ok, noise} = Isotope.Noise.new()
iex> Isotope.Noise.noise_map(noise, {20, 20})