-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.go
48 lines (42 loc) · 1023 Bytes
/
model.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
package main
import (
"image"
"image/color"
)
// SimulatedAnnealingEngine is the engine that manages the annealing simulation
type SimulatedAnnealingEngine interface {
Iterate() error
ToPixels() []byte
GetSnapshot() image.Image
}
// VoronoiDiagram is the voronoi engine used by the annealing engine
type VoronoiDiagram interface {
Init()
Tessellate() error
Perturbate() error
ToPixels() []byte
ToImage() image.Image
GetSeeds() []Point
WithSeeds([]Point)
}
// TargetImage is the struct containing info about the target image: its name, size, and the RGBA values of its pixels
type TargetImage struct {
Name string
Bytes []byte
Width int
Height int
}
// Point is the struct modeling a point of the Voronoi diagram, with its position, color, and distance from the center of the seed
type Point struct {
X int
Y int
Distance *int
Color *color.RGBA
}
// abs is a utility function to compute the absolute value of an int
func abs(x int) int {
if x < 0 {
return -x
}
return x
}