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

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

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.

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

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

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

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

Link to this function

chunk(noise, start_point, width, height)

View Source
@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)
@spec 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()
@spec 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})
@spec 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})