mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-22 21:17:33 +00:00
37 lines
795 B
Go
37 lines
795 B
Go
// Copyright (c) 2023-2024 David Vogel
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
package main
|
|
|
|
import (
|
|
"image"
|
|
"image/color"
|
|
)
|
|
|
|
type SubStitchedImage struct {
|
|
*StitchedImage // The original stitched image.
|
|
|
|
bounds image.Rectangle // The new bounds of the cropped image.
|
|
}
|
|
|
|
// Bounds returns the domain for which At can return non-zero color.
|
|
// The bounds do not necessarily contain the point (0, 0).
|
|
func (s SubStitchedImage) Bounds() image.Rectangle {
|
|
return s.bounds
|
|
}
|
|
|
|
func (s SubStitchedImage) At(x, y int) color.Color {
|
|
return s.RGBAAt(x, y)
|
|
}
|
|
|
|
func (s SubStitchedImage) RGBAAt(x, y int) color.RGBA {
|
|
point := image.Point{X: x, Y: y}
|
|
if !point.In(s.bounds) {
|
|
return colorBackground
|
|
}
|
|
|
|
return s.StitchedImage.RGBAAt(x, y)
|
|
}
|