Perf
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user