package blank

import (
	"image"
	"image/color"

	"git.nkpl.cc/twocookedfaggots/imageutils"
)

type blank struct {
	image.Image
	color.Color
	imageutils.Side
}

func (b blank) ColorModel() color.Model { return b.Image.ColorModel() }

func (b blank) Bounds() image.Rectangle {
	rect := image.Rectangle{}
	switch b.Side {
	case imageutils.Left:
		fallthrough
	case imageutils.Right:
		rect = image.Rectangle{
			image.ZP,
			image.Point{
				1, b.Image.Bounds().Dy(),
			},
		}
	case imageutils.Up:
		fallthrough
	case imageutils.Down:
		rect = image.Rectangle{
			image.ZP,
			image.Point{
				b.Image.Bounds().Dx(), 1,
			},
		}
	}
	return rect
}

func (b blank) At(x, y int) color.Color { return b.Color }

func Blank(img image.Image, clr color.Color, side imageutils.Side) image.Image {
	return imageutils.Concat(img, blank{img, clr, side}, side)
}
