diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2023-09-19 06:47:50 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2023-09-19 06:48:50 +0200 |
| commit | 0305cd01f8438d2c23033958120e61dff4fd2b1b (patch) | |
| tree | 41beb17a71d881f162aaddcd9d721cd39aac6df3 /selection.go | |
| parent | dc17461910194815ff9b329f386f17d6218a5853 (diff) | |
fix: Display selection rect above all entities
Diffstat (limited to 'selection.go')
| -rw-r--r-- | selection.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/selection.go b/selection.go index 9b6dbb2..730570a 100644 --- a/selection.go +++ b/selection.go @@ -1,13 +1,15 @@ package main import ( + "image/color" + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/vector" "golang.org/x/exp/slog" ) type Selection struct { - IsSelected bool - SelectedImage *ebiten.Image + IsSelected bool } func (e *Entity) SelectMultiple(cursor Point, selection GlobalSelection) { @@ -32,3 +34,11 @@ func (e *Entity) SelectSingle(cursor Point, canBeSelected bool) bool { } return false } + +func DrawSelection(screen *ebiten.Image, e *Entity) { + if e.Image.IsEnabled && e.Position.IsEnabled && e.Selection.IsEnabled { + if e.Selection.Value.IsSelected { + vector.StrokeRect(screen, float32(e.Position.Value.X-5), float32(e.Position.Value.Y-5), 110, 110, 10, color.RGBA{0xff, 0x00, 0x00, 0xff}, false) + } + } +} |
