This commit is contained in:
2025-11-19 09:20:06 -07:00
parent 8eb5909919
commit 1098e383ce
2 changed files with 33 additions and 8 deletions

View File

@@ -14,8 +14,15 @@ import (
var (
basicFace = text.NewGoXFace(basicfont.Face7x13)
basicFaceAscent = basicFace.Metrics().HAscent
rectPixel = newRectPixel()
)
func newRectPixel() *ebiten.Image {
img := ebiten.NewImage(1, 1)
img.Fill(color.White)
return img
}
func drawHUDText(screen *ebiten.Image, txt string, clr color.Color, x, y int) {
if clr == nil {
clr = color.White
@@ -132,16 +139,16 @@ func drawRect(screen *ebiten.Image, x, y, width, height int, clr color.Color) {
if width <= 0 || height <= 0 {
return
}
// Create a small 1x1 pixel image and scale it
img := ebiten.NewImage(1, 1)
img.Fill(clr)
if clr == nil {
clr = color.White
}
op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(float64(width), float64(height))
op.GeoM.Translate(float64(x), float64(y))
op.ColorScale.ScaleWithColor(clr)
screen.DrawImage(img, op)
screen.DrawImage(rectPixel, op)
}
// Empty padding block.