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() { func init() {
emptyImage, _ = ebiten.NewImage(1, 1) emptyImage, _ = ebiten.NewImage(1, 1)
_ = emptyImage.Fill(color.White) emptyImage.Fill(color.White)
} }
// DrawLine draws a line segment on the given destination dst. // 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. // Clear resets the pixels of the image into 0.
// //
// When the image is disposed, Clear does nothing. // When the image is disposed, Clear does nothing.
// func (i *Image) Clear() {
// Clear always returns nil as of 1.5.0.
func (i *Image) Clear() error {
i.Fill(color.Transparent) i.Fill(color.Transparent)
return nil
} }
// Fill fills the image with a solid color. // Fill fills the image with a solid color.
// //
// When the image is disposed, Fill does nothing. // When the image is disposed, Fill does nothing.
// func (i *Image) Fill(clr color.Color) {
// Fill always returns nil as of 1.5.0.
func (i *Image) Fill(clr color.Color) error {
i.copyCheck() i.copyCheck()
if i.isDisposed() { if i.isDisposed() {
return nil return
} }
// TODO: Implement this. // TODO: Implement this.
@ -92,7 +87,6 @@ func (i *Image) Fill(clr color.Color) error {
} }
i.mipmap.Fill(color.RGBAModel.Convert(clr).(color.RGBA)) i.mipmap.Fill(color.RGBAModel.Convert(clr).(color.RGBA))
return nil
} }
func canSkipMipmap(geom GeoM, filter driver.Filter) bool { func canSkipMipmap(geom GeoM, filter driver.Filter) bool {

View File

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