Files
games/common/elements/v1/stack.go
2025-08-28 08:33:31 -04:00

32 lines
649 B
Go

package elements
import "github.com/hajimehoshi/ebiten/v2"
type StackOption func(*stack)
func Stack(ops ...StackOption) ElementFunc {
return func(parentDimensions Dimensions) Element {
}
}
type stack struct {
block
horizontal bool
children []Element
}
func (s *stack) Draw(image *ebiten.Image, anchorX, anchorY float64) (w, h float64) {
var offsetX, offsetY float64
originalX, originalY := anchorX, anchorY
for i := range s.children {
offsetX, offsetY = s.children[i].Draw(image, anchorX, anchorY)
if s.horizontal {
anchorX += offsetX
} else {
anchorY += offsetY
}
}
return anchorX - originalX, anchorY - originalY
}