-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
62 lines (47 loc) · 949 Bytes
/
main.go
File metadata and controls
62 lines (47 loc) · 949 Bytes
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
package main
import (
"./fractalimage"
"log"
"fmt"
"math/cmplx"
)
func main() {
// Change these variables
// width of image
w := 1920
h := 1080
// inverse zoom factor
scale := float64(0.001)
// point to zoom in on
point := complex(0.34,0.068)
// OK probably don't change these
aspect := float64(w) / float64(h)
ds := complex(scale * aspect, scale)
tl := point - ds / 2
br := point + ds / 2
img := fractalimage.NewFractalImage(tl, br, w, h)
dx, dy := img.Dx(), img.Dy()
for y := 0; y < dy; y++ {
for x := 0; x < dx; x++ {
var c complex128 = img.ImagCoordsFromPixelCoords(x, y)
var p complex128
var d int
for {
m := cmplx.Abs(p)
if m > 1e50 {
break
}
d++
if d >= 100 {
break
}
p = cmplx.Pow(p, 2) + c
}
img.Set(x, y, d)
}
}
err := img.ToFile(fmt.Sprintf("mandlebrot-%G-%G-%dx%d.png", tl, br, img.Dx(), img.Dy()))
if err != nil {
log.Fatal(err)
}
}