diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-02-09 21:01:34 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-02-09 21:01:34 -0500 |
| commit | 5fde17eafa11bf397bbf1f18864b8ee26d9a701d (patch) | |
| tree | 6a49da06e7a9ef1faa3c99a4067e561ed077349d /layout/subimage.go | |
| parent | 5de30aee491087fa3b58c8bd629353e1133f28ba (diff) | |
| download | gui-5fde17eafa11bf397bbf1f18864b8ee26d9a701d.zip | |
add region layout
Diffstat (limited to 'layout/subimage.go')
| -rw-r--r-- | layout/subimage.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/layout/subimage.go b/layout/subimage.go new file mode 100644 index 0000000..ecbe931 --- /dev/null +++ b/layout/subimage.go @@ -0,0 +1,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) +} |