Refactored the menu system

This commit is contained in:
maze authored and maze committed 2026-10-29 17:29:54 +01:00
1 parent 4ae7655cd8
commit 86aad51e37
12 files changed
+474 -344

No files matched your search

+38
View File
@@ -124,3 +124,41 @@ func (i HorizontalWrappingImage) Bounds() image.Rectangle {
Max: bounds.Max.Add(delta),
}
}
type imageView struct {
draw.Image
Rect image.Rectangle
}
func ImageView(dst draw.Image, rect image.Rectangle) draw.Image {
return imageView{
Image: dst,
Rect: rect,
}
}
func (i imageView) Bounds() image.Rectangle {
return image.Rectangle{
Max: i.Rect.Max.Sub(i.Rect.Min),
}
}
func (i imageView) At(x, y int) color.Color {
// Translate x, y to inside our view
x += i.Rect.Min.X
y += i.Rect.Min.Y
if !(image.Point{X: x, Y: y}).In(i.Rect) {
return color.Transparent
}
return i.Image.At(x, y)
}
func (i imageView) Set(x, y int, c color.Color) {
// Translate x, y to inside our view
x += i.Rect.Min.X
y += i.Rect.Min.Y
if !(image.Point{X: x, Y: y}).In(i.Rect) {
return
}
i.Image.Set(x, y, c)
}