graphics: Use 1x1 image for empty images

This change leaves some empty images for DrawTriangles.
This commit is contained in:
Hajime Hoshi 2019-07-30 23:09:57 +09:00
parent b210339786
commit fc42af208d
3 changed files with 4 additions and 8 deletions

View File

@ -26,7 +26,7 @@ var (
) )
func init() { func init() {
emptyImage, _ = ebiten.NewImage(16, 16, ebiten.FilterDefault) emptyImage, _ = ebiten.NewImage(1, 1, ebiten.FilterDefault)
_ = emptyImage.Fill(color.White) _ = emptyImage.Fill(color.White)
} }

View File

@ -81,13 +81,8 @@ func (i *Image) Clear() error {
var emptyImage *Image var emptyImage *Image
func init() { func init() {
const w, h = 16, 16 emptyImage, _ = NewImage(1, 1, FilterDefault)
emptyImage, _ = NewImage(w, h, FilterDefault) emptyImage.ReplacePixels([]byte{0xff, 0xff, 0xff, 0xff})
pix := make([]byte, 4*w*h)
for i := range pix {
pix[i] = 0xff
}
emptyImage.ReplacePixels(pix)
} }
// Fill fills the image with a solid color. // Fill fills the image with a solid color.

View File

@ -33,6 +33,7 @@ func init() {
for i := range pix { for i := range pix {
pix[i] = 0xff pix[i] = 0xff
} }
// (*Image).Fill uses emptyImage, then Fill cannot be called here.
emptyImage.ReplacePixels(pix) emptyImage.ReplacePixels(pix)
} }