mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Bug fix: wrong region on a subimage
This commit is contained in:
parent
ebffaeba3d
commit
03c800cb9b
@ -513,8 +513,8 @@ func TestImageEdge(t *testing.T) {
|
||||
const (
|
||||
img0Width = 16
|
||||
img0Height = 16
|
||||
img0InnerWidth = 6
|
||||
img0InnerHeight = 6
|
||||
img0InnerWidth = 10
|
||||
img0InnerHeight = 10
|
||||
img0OffsetWidth = (img0Width - img0InnerWidth) / 2
|
||||
img0OffsetHeight = (img0Height - img0InnerHeight) / 2
|
||||
|
||||
@ -528,7 +528,7 @@ func TestImageEdge(t *testing.T) {
|
||||
idx := 4 * (i + j*img0Width)
|
||||
switch {
|
||||
case img0OffsetWidth <= i && i < img0Width-img0OffsetWidth &&
|
||||
img0InnerHeight <= j && j < img0Height-img0InnerHeight:
|
||||
img0OffsetHeight <= j && j < img0Height-img0OffsetHeight:
|
||||
pixels[idx] = 0xff
|
||||
pixels[idx+1] = 0
|
||||
pixels[idx+2] = 0
|
||||
@ -555,14 +555,14 @@ func TestImageEdge(t *testing.T) {
|
||||
angles = append(angles, float64(a)/4096*2*math.Pi)
|
||||
}
|
||||
|
||||
img0Sub := img0.SubImage(image.Rect(img0OffsetWidth, img0InnerHeight, img0Width-img0OffsetWidth, img0Height-img0InnerHeight)).(*Image)
|
||||
img0Sub := img0.SubImage(image.Rect(img0OffsetWidth, img0OffsetHeight, img0Width-img0OffsetWidth, img0Height-img0OffsetHeight)).(*Image)
|
||||
|
||||
for _, s := range []float64{1, 0.5, 0.25} {
|
||||
for _, f := range []Filter{FilterNearest, FilterLinear} {
|
||||
for _, a := range angles {
|
||||
img1.Clear()
|
||||
op := &DrawImageOptions{}
|
||||
w, h := img0.Size()
|
||||
w, h := img0Sub.Size()
|
||||
op.GeoM.Translate(-float64(w)/2, -float64(h)/2)
|
||||
op.GeoM.Scale(s, s)
|
||||
op.GeoM.Rotate(a)
|
||||
@ -587,11 +587,10 @@ func TestImageEdge(t *testing.T) {
|
||||
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.Fatalf("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 {
|
||||
if allTransparent {
|
||||
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