blob: 760a149829ed6ba6b984d9982149dd0b41d8ad80 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package layout
import (
"image"
"image/color"
"image/draw"
)
// subimager is implemented by most Image types.
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)
}
// drawBackground returns a draw call that fills the entire image with a color.
func drawBackground(c color.Color) func(draw.Image) image.Rectangle {
return func(img draw.Image) image.Rectangle {
draw.Draw(img, img.Bounds(), &image.Uniform{c}, image.ZP, draw.Src)
return img.Bounds()
}
}
|