View Source Isotope.Noise (Isotope v0.2.0)
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
which has width
and height
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
A coordinate {x, y}
in a cartesian plane.
@type noise_ref() :: reference()
A reference to the noise generator. This is needed for most of the library functions.
@type noisemap() :: [[float()]]
A noise map, represented by a list containing lists of floats (the noise values).
@type options() :: Isotope.Options.t()
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.
@type size() :: {non_neg_integer(), non_neg_integer()}
A tuple containing width and height
Link to this section Functions
@spec chunk(noise_ref(), coord(), non_neg_integer(), non_neg_integer()) :: noisemap()
Returns a 2D noise map from start_point
which has width
and height
iex> {:ok, noise} = Isotope.Noise.new(%Isotope.Options{seed: 100})
iex> Isotope.Noise.chunk(noise, {0, 0}, 100, 100)
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()
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})
Generates a 2D noise map of size
and returns it.
iex> {:ok, noise} = Isotope.Noise.new()
iex> Isotope.Noise.noise_map(noise, {20, 20})