mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
Add TestImageDotByDotInversion
This commit is contained in:
parent
7835f5cb2e
commit
d91a467c53
@ -19,6 +19,7 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
|
"math"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -145,4 +146,32 @@ func TestImageSelf(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestImageDotByDotInversion(t *testing.T) {
|
||||||
|
img0, _, err := openImage("testdata/ebiten.png")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w, h := img0.Size()
|
||||||
|
img1, err := NewImage(w, h, FilterNearest)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
op := &DrawImageOptions{}
|
||||||
|
op.GeoM.Rotate(2 * math.Pi / 2)
|
||||||
|
op.GeoM.Translate(float64(w), float64(h))
|
||||||
|
img1.DrawImage(img0, op)
|
||||||
|
|
||||||
|
for j := 0; j < h; j++ {
|
||||||
|
for i := 0; i < w; i++ {
|
||||||
|
c0 := img0.At(i, j).(color.RGBA)
|
||||||
|
c1 := img1.At(w-i-1, h-j-1).(color.RGBA)
|
||||||
|
if c0 != c1 {
|
||||||
|
t.Errorf("c0 should equal to c1 but not: c0: %v, c1: %v", c0, c1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Add more tests (e.g. DrawImage with color matrix)
|
// TODO: Add more tests (e.g. DrawImage with color matrix)
|
||||||
|
Loading…
Reference in New Issue
Block a user