package blocks import ( "git.vezzani.net/ben/games/common/elements/v1" "git.vezzani.net/ben/games/common/elements/v1/base" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/vector" ) type Builder elements.Builder func New(ops ...OptFunc) Builder { return func() elements.Element { b := Block{} for i := range ops { ops[i](&b) } return &b } } type Block struct { base.Element width, height int name string } func (b *Block) Bounds() elements.Bounds { return elements.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 }