ebiten: Remove returning values from (*Image).Clear and Fill

Updates #1380
This commit is contained in:
Hajime Hoshi 2020-10-06 00:01:40 +09:00
parent 944a19c6f7
commit c2ee8e8d59
3 changed files with 10 additions and 34 deletions

View File

@ -28,7 +28,7 @@ var (
func init() {
emptyImage, _ = ebiten.NewImage(1, 1)
_ = emptyImage.Fill(color.White)
emptyImage.Fill(color.White)
}
// DrawLine draws a line segment on the given destination dst.

View File

@ -67,23 +67,18 @@ func (i *Image) isSubImage() bool {
// Clear resets the pixels of the image into 0.
//
// When the image is disposed, Clear does nothing.
//
// Clear always returns nil as of 1.5.0.
func (i *Image) Clear() error {
func (i *Image) Clear() {
i.Fill(color.Transparent)
return nil
}
// Fill fills the image with a solid color.
//
// When the image is disposed, Fill does nothing.
//
// Fill always returns nil as of 1.5.0.
func (i *Image) Fill(clr color.Color) error {
func (i *Image) Fill(clr color.Color) {
i.copyCheck()
if i.isDisposed() {
return nil
return
}
// TODO: Implement this.
@ -92,7 +87,6 @@ func (i *Image) Fill(clr color.Color) error {
}
i.mipmap.Fill(color.RGBAModel.Convert(clr).(color.RGBA))
return nil
}
func canSkipMipmap(geom GeoM, filter driver.Filter) bool {

View File

@ -135,14 +135,8 @@ func TestImageComposition(t *testing.T) {
return
}
if err := img2.Fill(img2Color); err != nil {
t.Fatal(err)
return
}
if err := img3.Fill(img3Color); err != nil {
t.Fatal(err)
return
}
img2.Fill(img2Color)
img3.Fill(img3Color)
img_12_3, err := NewImage(w, h)
if err != nil {
t.Fatal(err)
@ -161,14 +155,8 @@ func TestImageComposition(t *testing.T) {
return
}
if err := img2.Fill(img2Color); err != nil {
t.Fatal(err)
return
}
if err := img3.Fill(img3Color); err != nil {
t.Fatal(err)
return
}
img2.Fill(img2Color)
img3.Fill(img3Color)
img_1_23, err := NewImage(w, h)
if err != nil {
t.Fatal(err)
@ -428,10 +416,7 @@ func TestImageCompositeModeLighter(t *testing.T) {
t.Fatal(err)
return
}
if err := img1.Fill(color.RGBA{0x01, 0x02, 0x03, 0x04}); err != nil {
t.Fatal(err)
return
}
img1.Fill(color.RGBA{0x01, 0x02, 0x03, 0x04})
op := &DrawImageOptions{}
op.CompositeMode = CompositeModeLighter
if err := img1.DrawImage(img0, op); err != nil {
@ -512,10 +497,7 @@ func TestImageFill(t *testing.T) {
return
}
clr := &mutableRGBA{0x80, 0x80, 0x80, 0x80}
if err := img.Fill(clr); err != nil {
t.Fatal(err)
return
}
img.Fill(clr)
clr.r = 0
for j := 0; j < h; j++ {
for i := 0; i < w; i++ {