package blocks import ( "image/color" "git.vezzani.net/ben/games/common/elements/v1/core" "git.vezzani.net/ben/games/common/geo" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/vector" ) func New(ops ...OptFunc) *Block { b := &Block{} for i := range ops { ops[i](b) } return b } type Block struct { core.Element backgroundColor *color.Color width, height int name string } func (b *Block) Bounds() geo.Bounds { return geo.Bounds{ Min: b.Anchor(), Width: b.width, Height: b.height, } } func (b *Block) Size() (w, h int) { return b.width, b.height } func (b *Block) Draw(image *ebiten.Image) { bnd := b.Bounds() if b.backgroundColor != nil { vector.DrawFilledRect( image, float32(b.Anchor().X), float32(b.Anchor().Y), float32(bnd.Width), float32(bnd.Height), *b.backgroundColor, true, ) } return }