stream_perlin v0.1.1 StreamPerlin
Generate a potentially infinite stream of floats betyween -1 and 1 which vary smoothly using a 1d Perlin algorithm.
The low-level API is
sp = StreamPerlin.initialize(period)
{val, sp} = StreamPerlin.next(sp)
{val, sp} = StreamPerlin.next(sp)
: :
{val, sp} = StreamPerlin.next(sp)
Alternatively, you can generate a stream of values using
StreamPerlin.generate(period)
The period is a positive integer. It determines the number of values that are interpolated between new random points. The interpolation is eased using a quintic with zero first and second derivatives at 0 and 1, ensuring the curve is continuous and smooth as it moves between random values.
Good values of period
depend on how jagged you want your data, and
how many samples you typically take. Values between 5 and 20 seem
like a good starting point.
If you need more complex data, you can apply Perlin’s octaves technique.
Summary
Functions
Return a stream of random-ish floats between -1 and 1, where the values tend to change smoothly. This is useful when generating data that is supposed to look natural
If you want an external iterator, then use
Functions
Return a stream of random-ish floats between -1 and 1, where the values tend to change smoothly. This is useful when generating data that is supposed to look natural.
Usage
StreamPerlin.generate(n)
generates a stream of floats. See the module doc for StreamPerlin for details.
If you want an external iterator, then use
sp = StreamPerlin.initialize(n)
then
{ next_val, new_sp } = StreamPerlin.next(sp)