aboutsummaryrefslogtreecommitdiffstats
path: root/layout/subimage.go
blob: ecbe9319cf9122b048aceac843aa1a1d0add03e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package layout

import (
	"image"
	"image/draw"
)

type subimager interface {
	SubImage(image.Rectangle) image.Image
}

// Subimage returns an image representing the portion of the image m visible through r.
// The returned value shares pixels with the original.
// Panics if the concrete image type does not have a SubImage() method.
func subimage(m draw.Image, r image.Rectangle) draw.Image {
	return m.(subimager).SubImage(r).(draw.Image)
}