-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.go
More file actions
77 lines (62 loc) · 1.54 KB
/
Copy pathdebug.go
File metadata and controls
77 lines (62 loc) · 1.54 KB
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
70
71
72
73
74
75
76
77
package main
import (
"image/color"
"math"
raylib "github.com/gen2brain/raylib-go/raylib"
)
func debug_draw_circle() {
c := centerVector(0, 0)
raylib.DrawRing(c, r, r+1, 0, 360, 1, raylib.Red)
}
func debug_draw_pins() {
for _, pin := range pins {
raylib.DrawCircleV(pin, 1, raylib.Lime)
}
}
func debug_draw_potential_lines() {
for _, l := range lines {
raylib.DrawLineStrip(l.pixels, int32(len(l.pixels)), raylib.DarkGreen)
}
}
func debug_draw_potential_line_px() {
for _, l := range lines {
for _, px := range l.pixels {
raylib.DrawPixelV(px, raylib.Brown)
}
}
}
func debug_draw_potential_lines_img() {
for _, l := range lines {
for _, px := range l.pixels {
x := int(px.X) - WIDTH/2 + bounds.Max.X/2
y := int(px.Y) - HEIGHT/2 + bounds.Max.Y/2
i := y*bounds.Max.X + x
var c color.RGBA
if i < 0 || i > len(grayscale)-1 {
c = raylib.Red
} else {
g := uint8(grayscale[i])
c = color.RGBA{g, g, g, 255}
}
raylib.DrawPixelV(px, c)
}
}
}
func debug_draw_image() {
for x := 0; x < bounds.Max.X; x++ {
for y := 0; y < bounds.Max.Y; y++ {
i := y*bounds.Max.X + x
// cx -> x position if center is (0,0)
cx := float32(x - bounds.Max.X/2)
// cy -> y position if center is (0,0)
cy := float32(y - bounds.Max.Y/2)
// If not in bounds of the circle
isInBounds := math.Pow(float64(cx), 2)+math.Pow(float64(cy), 2) <= math.Pow(float64(r), 2)
if !isInBounds {
continue
}
v := uint8(grayscale[i])
raylib.DrawPixelV(centerVector(cx, cy), color.RGBA{v, v, v, 255})
}
}
}