Skip to content

Commit

Permalink
graphics: Use 1x1 image for empty images
Browse files Browse the repository at this point in the history
This change leaves some empty images for DrawTriangles.
  • Loading branch information
hajimehoshi committed Jul 30, 2019
1 parent b210339 commit fc42af2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ebitenutil/shapes.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (
)

func init() {
emptyImage, _ = ebiten.NewImage(16, 16, ebiten.FilterDefault)
emptyImage, _ = ebiten.NewImage(1, 1, ebiten.FilterDefault)
_ = emptyImage.Fill(color.White)
}

Expand Down
9 changes: 2 additions & 7 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,8 @@ func (i *Image) Clear() error {
var emptyImage *Image

func init() {
const w, h = 16, 16
emptyImage, _ = NewImage(w, h, FilterDefault)
pix := make([]byte, 4*w*h)
for i := range pix {
pix[i] = 0xff
}
emptyImage.ReplacePixels(pix)
emptyImage, _ = NewImage(1, 1, FilterDefault)
emptyImage.ReplacePixels([]byte{0xff, 0xff, 0xff, 0xff})
}

// Fill fills the image with a solid color.
Expand Down
1 change: 1 addition & 0 deletions vector/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func init() {
for i := range pix {
pix[i] = 0xff
}
// (*Image).Fill uses emptyImage, then Fill cannot be called here.
emptyImage.ReplacePixels(pix)
}

Expand Down

0 comments on commit fc42af2

Please sign in to comment.