-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
69 lines (61 loc) · 2.42 KB
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package mandelbrot_test
import (
"fmt"
mandelbrot "github.com/t-pwk/go-mandelbrot"
)
// Example of a small Mandelbrot set composed of 400 numbers (20 x 20) with 9 set to maximum iteration
func Example() {
m := mandelbrot.Mandelbrot(mandelbrot.Min, mandelbrot.Max, 20, 20, 9)
for i := range m {
fmt.Println(m[i])
}
// Output:
// [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
// [0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0]
// [0 0 0 0 0 1 1 1 1 1 1 2 4 3 2 1 0 0 0 0]
// [0 0 0 0 1 1 1 1 1 2 2 3 5 9 3 2 1 1 0 0]
// [0 0 0 1 1 1 1 1 2 2 3 4 9 9 5 3 2 1 1 0]
// [0 0 1 1 1 1 1 2 3 4 9 9 9 9 9 6 9 2 1 1]
// [0 1 1 1 1 2 3 3 4 6 9 9 9 9 9 9 9 3 1 1]
// [0 1 1 2 3 9 5 6 6 9 9 9 9 9 9 9 9 3 1 1]
// [0 2 2 3 3 8 9 9 9 9 9 9 9 9 9 9 9 3 2 1]
// [0 3 4 5 9 9 9 9 9 9 9 9 9 9 9 9 9 3 2 1]
// [0 3 4 5 9 9 9 9 9 9 9 9 9 9 9 9 9 3 2 1]
// [0 2 2 3 3 8 9 9 9 9 9 9 9 9 9 9 9 3 2 1]
// [0 1 1 2 3 9 5 6 6 9 9 9 9 9 9 9 9 3 1 1]
// [0 1 1 1 1 2 3 3 4 6 9 9 9 9 9 9 9 3 1 1]
// [0 0 1 1 1 1 1 2 3 4 9 9 9 9 9 6 9 2 1 1]
// [0 0 0 1 1 1 1 1 2 2 3 4 9 9 5 3 2 1 1 0]
// [0 0 0 0 1 1 1 1 1 2 2 3 5 9 3 2 1 1 0 0]
// [0 0 0 0 0 1 1 1 1 1 1 2 4 3 2 1 0 0 0 0]
// [0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0]
// [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
}
// Example of a small Mandelbrot set composed of 400 numbers (20 x 20) with 9 set to maximum iteration presenting so called Elephant Valley
func Example_elephantValley() {
m := mandelbrot.Mandelbrot(0.25+0.05i, 0.35-0.05i, 20, 20, 9)
for i := range m {
fmt.Println(m[i])
}
// Output:
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 7]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 7 7]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 7 7 7]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 7 7 7]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 7 7 7 6]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 7 7 7 6]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 8 7 7 7 6]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 8 7 7 7 6]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 8 7 7 7 6]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 8 7 7 7 6]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 7 7 7 6]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 7 7 7 6]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 7 7 7]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 7 7 7]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 7 7]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 7]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8]
// [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8]
}