Refactored the menu system
This commit is contained in:
12 files changed
+474
-344
No files matched your search
@@ -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)
|
||||
}
|
||||
Reference in new issue
Block a user