mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add tests about #732
|
|
||||||
bounds := img.Bounds()
|
bounds := img.Bounds()
|
||||||
sx0, sy0, sx1, sy1 := bounds.Min.X, bounds.Min.Y, bounds.Max.X, bounds.Max.Y
|
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.GeoM.Translate(img1Width/2, img1Height/2)
|
||||||
op.Filter = f
|
op.Filter = f
|
||||||
img1.DrawImage(img0Sub, op)
|
img1.DrawImage(img0Sub, op)
|
||||||
|
allTransparent := true
|
||||||
for j := 0; j < img1Height; j++ {
|
for j := 0; j < img1Height; j++ {
|
||||||
for i := 0; i < img1Width; i++ {
|
for i := 0; i < img1Width; i++ {
|
||||||
c := img1.At(i, j)
|
c := img1.At(i, j)
|
||||||
if c == transparent {
|
if c == transparent {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
allTransparent = false
|
||||||
switch f {
|
switch f {
|
||||||
case FilterNearest:
|
case FilterNearest:
|
||||||
if c == red {
|
if c == red {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case FilterLinear:
|
case FilterLinear:
|
||||||
_, g, b, _ := c.RGBA()
|
if _, g, b, _ := c.RGBA(); g == 0 && b == 0 {
|
||||||
if g == 0 && b == 0 {
|
|
||||||
continue
|
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)
|
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