Documentation ¶
Overview ¶
opensimplex is a Go implementation of Kurt Spencer's patent-free alternative to Perlin and Simplex noise.
Given a seed, it generates smoothly-changing deterministic random values in 2, 3 or 4 dimensions. It's commonly used for procedurally generated images, geometry, or other randomly-influenced applications that require a random gradient.
For more information on OpenSimplex noise, read more from the creator of the algorithm: http://uniblock.tumblr.com/post/97868843242/noise
Example ¶
noise := New(rand.Int63()) w, h := 100, 100 heightmap := make([]float64, w*h) for y := 0; y < h; y++ { for x := 0; x < w; x++ { xFloat := float64(x) / float64(w) yFloat := float64(y) / float64(h) heightmap[(y*w)+x] = noise.Eval2(xFloat, yFloat) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Noise ¶
type Noise interface { Eval2(x, y float64) float64 Eval3(x, y, z float64) float64 Eval4(x, y, z, w float64) float64 }
A seeded 64-bit noise instance
func New ¶
Construct a Noise instance with a 64-bit seed. Two Noise instances with the same seed will have the same output.
func NewNormalized ¶
Construct a normalized Noise instance with a 64-bit seed. Eval methods will return values in [0, 1). Two Noise instances with the same seed will have the same output.
type Noise32 ¶
type Noise32 interface { Eval2(x, y float32) float32 Eval3(x, y, z float32) float32 Eval4(x, y, z, w float32) float32 }
A seeded 32-bit noise instance
func New32 ¶
Construct a Noise32 instance with a 64-bit seed. Two Noise32 instances with the same seed will have the same output.
func NewNormalized32 ¶
Construct a normalized Noise32 instance with a 64-bit seed. Eval methods will return values in [0, 1). Two Noise32 instances with the same seed will have the same output.