-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.go
51 lines (38 loc) · 1.02 KB
/
utils.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
package main
import (
"image"
"image/color"
"os"
qt "github.com/etic4/quadtree"
vec "github.com/etic4/vecmath"
)
func getWidthHeight(filename string) (int, int) {
f, err := os.Open(filename)
if err != nil {
panic("Peut pas ouvrir le fichier")
}
defer f.Close()
img, _, _ := image.Decode(f)
bounds := img.Bounds()
return bounds.Max.X, bounds.Max.Y
}
func getQtree() *qt.Quadtree {
c := vec.Vec2{X: float64(screenWidth / 2), Y: float64(screenHeight / 2)}
rect := qt.NewRectangleCentered(c, float64(screenWidth/2), float64(screenHeight/2))
return qt.NewQuadtree(rect, 4, nil)
}
//enlève de liste
func pop(points []*point, i int) ([]*point, *point) {
pt := points[i]
points[i] = points[len(points)-1]
points[len(points)-1] = new(point)
points = points[:len(points)-1]
return points, pt
}
func popColor(colors []*color.RGBA, i int) ([]*color.RGBA, *color.RGBA) {
col := colors[i]
colors[i] = colors[len(colors)-1]
colors[len(colors)-1] = new(color.RGBA)
colors = colors[:len(colors)-1]
return colors, col
}