29 lines
523 B
Go
29 lines
523 B
Go
package draw
|
|
|
|
import (
|
|
"image"
|
|
"image/draw"
|
|
)
|
|
|
|
type Drawer interface {
|
|
Draw(img *image.Image)
|
|
}
|
|
|
|
type BaseBoard struct {
|
|
Image *image.RGBA64
|
|
}
|
|
|
|
func (b *BaseBoard) SetBaseImage(img *image.Image) {
|
|
b.Image = ToRGBA64(img)
|
|
}
|
|
|
|
func (b *BaseBoard) Draw(img *image.Image, pos image.Point) {
|
|
draw.Draw(b.Image, b.Image.Bounds(), *img, pos, draw.Over)
|
|
}
|
|
|
|
func ToRGBA64(img *image.Image) *image.RGBA64 {
|
|
rgba := image.NewRGBA64((*img).Bounds())
|
|
draw.Draw(rgba, rgba.Bounds(), *img, image.Point{}, draw.Over)
|
|
return rgba
|
|
}
|