-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommand.go
77 lines (65 loc) · 1.29 KB
/
command.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
package debugui
import (
"image"
"image/color"
"iter"
"github.com/hajimehoshi/ebiten/v2"
)
const (
commandClip = 1 + iota
commandRect
commandText
commandIcon
commandDraw
)
type clipCommand struct {
rect image.Rectangle
}
type rectCommand struct {
rect image.Rectangle
color color.Color
}
type textCommand struct {
pos image.Point
color color.Color
str string
}
type iconCommand struct {
rect image.Rectangle
icon icon
color color.Color
}
type drawCommand struct {
f func(screen *ebiten.Image)
}
type command struct {
typ int
clip clipCommand
rect rectCommand
text textCommand
icon iconCommand
draw drawCommand
}
// appendCommand adds a new command with type cmdType to the command list.
func (c *Context) appendCommand(cmdType int) *command {
cmd := command{
typ: cmdType,
}
cnt := c.currentRootContainer()
cnt.commandList = append(cnt.commandList, &cmd)
return &cmd
}
// commands returns a sequence of commands from all root containers.
func (c *Context) commands() iter.Seq[*command] {
return func(yield func(command *command) bool) {
for _, cnt := range c.rootContainers {
for _, cmd := range cnt.commandList {
if !yield(cmd) {
return
}
}
}
}
}