mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Bug fix: (*Image).At must return color.RGBA type value
This commit is contained in:
parent
680656e6e9
commit
a9a1fba7e7
4
image.go
4
image.go
@ -163,12 +163,12 @@ func (i *Image) ColorModel() color.Model {
|
||||
//
|
||||
// At loads pixels from GPU to system memory if necessary, which means that At can be slow.
|
||||
//
|
||||
// At always returns color.Transparend if the image is disposed.
|
||||
// At always returns a transparent color if the image is disposed.
|
||||
//
|
||||
// At can't be called before the main loop (ebiten.Run) starts (as of version 1.4.0-alpha).
|
||||
func (i *Image) At(x, y int) color.Color {
|
||||
if i.restorable == nil {
|
||||
return color.Transparent
|
||||
return color.RGBA{}
|
||||
}
|
||||
// TODO: Error should be delayed until flushing. Do not panic here.
|
||||
clr, err := i.restorable.At(x, y)
|
||||
|
@ -378,9 +378,18 @@ func TestImageDispose(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
img.Fill(color.White)
|
||||
if err := img.Dispose(); err != nil {
|
||||
t.Errorf("img.Dipose() returns error: %v", err)
|
||||
}
|
||||
|
||||
// The color is transparent (color.RGBA{}).
|
||||
// Note that the value's type must be color.RGBA.
|
||||
got := img.At(0, 0)
|
||||
want := color.RGBA{}
|
||||
if got != want {
|
||||
t.Errorf("img.At(0, 0) got: %v, want: %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func min(a, b int) int {
|
||||
|
Loading…
Reference in New Issue
Block a user