Noisex.Noise (Noisex v0.1.3-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
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() :: Noisex.Options.t()
Options available when initializing the noise.
Specs
2-element tuple containg x and y values as floats.
Specs
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
Specs
Returns a 2D noise map from start_point
to end_point
iex> {:ok, noise} = Noisex.Noise.new(%Noisex.Options{seed: 100})
iex> Noisex.Noise.chunk(noise, {0, 0}, {100, 100})
Specs
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} = Noisex.Noise.new()
iex> Noisex.Noise.get_noise(noise, {10.0, 10.0})
-0.6350845098495483
iex> {:ok, noise} = Noisex.Noise.new()
iex> Noisex.Noise.get_noise(noise, {10.0, 10.0, 10.0})
-0.1322503685951233
Returns a new noise reference using the default options.
iex> {:ok, _ref} = Noisex.Noise.new()
Specs
Returns a new noise reference using the provided options
.
iex> {:ok, _ref} = Noisex.Noise.new(%Noisex.Options{seed: 100})
iex> {:error, :unsupported_noise} = Noisex.Noise.new(%Noisex.Options{noise_type: :foobar})
Specs
Generates a 2D noise map of size
and returns it.
iex> {:ok, noise} = Noisex.Noise.new()
iex> Noisex.Noise.noise_map(noise, {20, 20})