-
Notifications
You must be signed in to change notification settings - Fork 7
/
furex.go
54 lines (44 loc) · 1.04 KB
/
furex.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
package furex
import (
"image/color"
"github.com/hajimehoshi/ebiten/v2"
"github.com/yohamta/furex/v2/internal/graphic"
)
var (
Debug = false
debugColor = color.RGBA{0xff, 0, 0, 0xff}
debugColorShift = ebiten.ColorM{}
)
func debugBorders(screen *ebiten.Image, root containerEmbed) {
queue := []containerEmbed{}
queue = append(queue, root)
renderColor := resetDebugColor()
for len(queue) > 0 {
levelSize := len(queue)
for levelSize != 0 {
curr := queue[0]
queue = queue[1:]
graphic.DrawRect(screen, &graphic.DrawRectOpts{
Rect: curr.frame,
Color: renderColor,
StrokeWidth: 2,
})
for _, c := range curr.children {
if c.item.Display == DisplayNone {
continue
}
queue = append(queue, c.item.containerEmbed)
}
levelSize--
}
renderColor = rotateDebugColor()
}
}
func rotateDebugColor() color.Color {
debugColorShift.RotateHue(1.66)
return debugColorShift.Apply(debugColor)
}
func resetDebugColor() color.Color {
debugColorShift = ebiten.ColorM{}
return debugColor
}