Documentation ¶
Overview ¶
Package perlin implements reusable Perlin noise generators.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct { Alpha float64 // Alpha is the weight factor used during summing Beta float64 // Beta is the harmonic scaling/spacing factor N int // N is the number of octaves/samples Seed int64 // Seed is the number used to seed the RNG // contains filtered or unexported fields }
Generator holds Perlin noise parameters and random seed.
func NewGenerator ¶
NewGenerator returns seeded Generator for given parameters.
func (*Generator) Noise2D ¶
Noise2D calculates Perlin noise at point x,y.
Example ¶
g1 := NewGenerator(2, 2, 1, 41) g2 := NewGenerator(2, 2, 1, 4231) fmt.Printf("g1 noise at 0.1, 0.2 = %f\n", g1.Noise2D(0.1, 0.2)) fmt.Printf("g2 noise at 0.1, 0.2 = %f\n", g2.Noise2D(0.1, 0.2))
Output: g1 noise at 0.1, 0.2 = -0.125053 g2 noise at 0.1, 0.2 = 0.182675
Click to show internal directories.
Click to hide internal directories.