You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-9Lines changed: 25 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,10 @@ In the example below, 1 dimmentional method `Noise.Eval64(x)` was used to genera
14
14
//
15
15
// noiseType := noise.Perlin
16
16
// noiseType := noise.OpenSimplex
17
-
n:= noise.New(noiseType, seed)
17
+
n, err:= noise.New(noiseType, seed)
18
18
19
19
yy:= n.Eval64(x / smoothness) // yy is between -1.0 and 1.0 of float64
20
-
21
-
y:= (yy + 1) / 2 * 500// y is between 0 and 500
20
+
y:= (yy + 1) / 2 * 500// y is between 0 and 500
22
21
```
23
22
24
23

@@ -30,8 +29,8 @@ y := (yy + 1) / 2 * 500 // y is between 0 and 500
30
29
31
30
```go
32
31
// Obtain the noise value at the position (x, y)
33
-
n:= noise.New(noiseType, seed)
34
-
v:= n.Eval64(x, y) //y is between -1.0 and 1.0 of float64
32
+
n, err:= noise.New(noiseType, seed)
33
+
v:= n.Eval64(x, y) //v is between -1.0 and 1.0 of float64
35
34
```
36
35
37
36
To create a 2D image, plot the `v` value at the position `(x, y)` in the 2D space. The 2D image example is equivalent to a frame of the 3D image example below.
@@ -46,8 +45,8 @@ The X and Y axes are the 2D image and the Z axis is the "time", or animation fra
46
45
47
46
```go
48
47
// Obtain the noise value at the position (x, y, z)
49
-
n:= noise.New(noise.Perlin, seed)
50
-
v:= n.Eval64(x, y, z) //y is between -1.0 and 1.0 of float64
48
+
n, err:= noise.New(noise.Perlin, seed)
49
+
v:= n.Eval64(x, y, z) //v is between -1.0 and 1.0 of float64
51
50
```
52
51
53
52

@@ -58,8 +57,8 @@ v := n.Eval64(x, y, z) // y is between -1.0 and 1.0 of float64
58
57
59
58
```go
60
59
// Obtain the noise value at the position (x, y, z)
61
-
n:= noise.New(noise.OpenSimplex, seed)
62
-
v:= n.Eval64(x, y, z) //y is between -1.0 and 1.0 of float64
60
+
n, err:= noise.New(noise.OpenSimplex, seed)
61
+
v:= n.Eval64(x, y, z) //v is between -1.0 and 1.0 of float64
63
62
```
64
63
65
64

@@ -135,6 +134,10 @@ const frame = 50
135
134
// Create new noise generator of Perlin type
136
135
genNoise, err:= noise.New(noise.Perlin, seed)
137
136
137
+
if err != nil {
138
+
// error handle
139
+
}
140
+
138
141
forz:=0; z < frame; z++ {
139
142
zz:=float64(z) / steps
140
143
@@ -165,3 +168,16 @@ for z := 0; z < frame; z++ {
165
168
```
166
169
167
170
-[Complete Source](./_example/3d)
171
+
172
+
#### Advanced
173
+
174
+
To change `alpha` and `beta` values of Perling noise.
0 commit comments