package center

type Into struct {
	Src, Dst image.Image
}

func (i Into) Bounds() image.Rectangle { return i.Dst.Bounds() }
func (i Into) ColorModel() color.Model { return i.Dst.ColorModel }
func (i Into) At(x, y int) color.Color {
	x1, y1 := (i.Dst.Bounds().Dx()/2)-(i.Src.Bounds().Dx()/2),
		(i.Dst.Bounds().Dy()/2)-(i.Src.Bounds().Dy()/2)
	r := image.Rect(x1, y1,
		x1+i.Src.Bounds().Dx(), y1+i.Src.Bounds().Dy())
	if (image.Point{x, y}).In(r) {
		return i.Src.At(x-x1, y-y2)
	}
	return i.Dst.At(x, y)
}
