mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
graphics: Improve TestImageTooManyFill
This commit is contained in:
parent
f350f55088
commit
e206c16fc6
@ -559,6 +559,10 @@ func TestImageEdge(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func indexToColor(index int) uint8 {
|
||||||
|
return uint8((17 * index) % 256)
|
||||||
|
}
|
||||||
|
|
||||||
// Issue #419
|
// Issue #419
|
||||||
func TestImageTooManyFill(t *testing.T) {
|
func TestImageTooManyFill(t *testing.T) {
|
||||||
const width = 1024
|
const width = 1024
|
||||||
@ -566,15 +570,17 @@ func TestImageTooManyFill(t *testing.T) {
|
|||||||
src, _ := NewImage(1, 1, FilterNearest)
|
src, _ := NewImage(1, 1, FilterNearest)
|
||||||
dst, _ := NewImage(width, 1, FilterNearest)
|
dst, _ := NewImage(width, 1, FilterNearest)
|
||||||
for i := 0; i < width; i++ {
|
for i := 0; i < width; i++ {
|
||||||
src.Fill(color.RGBA{uint8(i), uint8(i), uint8(i), 0xff})
|
c := indexToColor(i)
|
||||||
|
src.Fill(color.RGBA{c, c, c, 0xff})
|
||||||
op := &DrawImageOptions{}
|
op := &DrawImageOptions{}
|
||||||
op.GeoM.Translate(float64(i), 0)
|
op.GeoM.Translate(float64(i), 0)
|
||||||
dst.DrawImage(src, op)
|
dst.DrawImage(src, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < width; i++ {
|
for i := 0; i < width; i++ {
|
||||||
|
c := indexToColor(i)
|
||||||
got := color.RGBAModel.Convert(dst.At(i, 0))
|
got := color.RGBAModel.Convert(dst.At(i, 0))
|
||||||
want := color.RGBA{uint8(i), uint8(i), uint8(i), 0xff}
|
want := color.RGBA{c, c, c, 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("src At(%d, %d): got %#v, want: %#v", i, 0, got, want)
|
t.Errorf("src At(%d, %d): got %#v, want: %#v", i, 0, got, want)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user