-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
59 lines (45 loc) · 1.15 KB
/
main.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
package main
import (
"math"
"github.com/aquilax/go-perlin"
)
func noiseFormula() Formula {
p := perlin.NewPerlin(2, 2, 3, 0)
return func(vector *Vector) *Vector {
n := p.Noise2D(vector.X/40, vector.Y/40) * 10
return NewVector(math.Cos(n+10), math.Sin(n))
}
}
/*
func identityFormula() core.Formula {
return func(vector *Vector) *Vector {
return vector
}
}
func noiseFormula() core.Formula {
p := perlin.NewPerlin(2, 2, 3, 0)
return func(vector *Vector) *Vector {
n := p.Noise2D(vector.X/40, vector.Y/40) * 10
return NewVector(math.Cos(n+10), math.Sin(n))
}
}
func circleFormula() core.Formula {
return func(vector *Vector) *Vector {
return NewVector(0, -1).Rotate((vector.Y / 20) * math.Pi)
}
}
func sineFormula() core.Formula {
return func(vector *Vector) *Vector {
return NewVector(math.Sin(vector.Y), math.Sin(vector.X))
}
}
func customFormula() core.Formula {
return func(vector *Vector) *Vector {
return NewVector((vector.X*vector.X - vector.Y*vector.Y), vector.X*vector.Y)
}
}*/
func main() {
field := NewVectorField(1920, 1080, noiseFormula(), 30, 500, 1, 1000, true)
context := Draw(field)
context.SavePNG("test.png")
}