mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Add tests for #732
This commit is contained in:
parent
f54bdfa159
commit
9f0d14dd05
1
image.go
1
image.go
@ -330,7 +330,6 @@ func (i *Image) drawImage(img *Image, options *DrawImageOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Add tests about #732
|
||||
bounds := img.Bounds()
|
||||
sx0, sy0, sx1, sy1 := bounds.Min.X, bounds.Min.Y, bounds.Max.X, bounds.Max.Y
|
||||
|
||||
|
@ -569,26 +569,31 @@ func TestImageEdge(t *testing.T) {
|
||||
op.GeoM.Translate(img1Width/2, img1Height/2)
|
||||
op.Filter = f
|
||||
img1.DrawImage(img0Sub, op)
|
||||
allTransparent := true
|
||||
for j := 0; j < img1Height; j++ {
|
||||
for i := 0; i < img1Width; i++ {
|
||||
c := img1.At(i, j)
|
||||
if c == transparent {
|
||||
continue
|
||||
}
|
||||
allTransparent = false
|
||||
switch f {
|
||||
case FilterNearest:
|
||||
if c == red {
|
||||
continue
|
||||
}
|
||||
case FilterLinear:
|
||||
_, g, b, _ := c.RGBA()
|
||||
if g == 0 && b == 0 {
|
||||
if _, g, b, _ := c.RGBA(); g == 0 && b == 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
t.Errorf("img1.At(%d, %d) (filter: %d, scale: %f, angle: %f) want: red or transparent, got: %v", i, j, f, s, a, c)
|
||||
}
|
||||
}
|
||||
// TODO: Fix bug for scale 0.25
|
||||
if allTransparent && s > 0.25 {
|
||||
t.Fatalf("img1 (filter: %d, scale: %f, angle: %f) is transparent but should not", f, s, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user