graphics: Use SourceRect at image_test.go

This commit is contained in:
Hajime Hoshi 2017-05-30 01:01:19 +09:00
parent c6c8ff22d7
commit 9c9c70e7ba

View File

@ -490,24 +490,6 @@ func TestImageFill(t *testing.T) {
} }
} }
type halfImagePart struct {
image *Image
}
func (p *halfImagePart) Len() int {
return 1
}
func (p *halfImagePart) Src(index int) (int, int, int, int) {
w, h := p.image.Size()
return 0, 0, w, h / 2
}
func (p *halfImagePart) Dst(index int) (int, int, int, int) {
w, h := p.image.Size()
return 0, 0, w, h / 2
}
// Issue 317 // Issue 317
func TestImageEdge(t *testing.T) { func TestImageEdge(t *testing.T) {
const ( const (
@ -555,7 +537,9 @@ func TestImageEdge(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
op := &DrawImageOptions{} op := &DrawImageOptions{}
op.ImageParts = &halfImagePart{img0} w, h := img0.Size()
r := image.Rect(0, 0, w, h/2)
op.SourceRect = &r
op.GeoM.Translate(-float64(img0Width)/2, -float64(img0Height)/2) op.GeoM.Translate(-float64(img0Width)/2, -float64(img0Height)/2)
op.GeoM.Rotate(float64(a) * math.Pi / 180) op.GeoM.Rotate(float64(a) * math.Pi / 180)
op.GeoM.Translate(img1Width/2, img1Height/2) op.GeoM.Translate(img1Width/2, img1Height/2)