Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
AnchorCenter is a predefined anchor that centers the element in both directions.
AnchorLeft aligns the left edges of the source and destination elements, and vertically centers it.
Functions ¶
This section is empty.
Types ¶
type Anchor ¶
type Anchor struct { // Src is a percentage of the source's bounding rectangle to use as an anchor point. // E.g (0, 0) uses is the top left as an anchor, and (1, 1) uses the bottom right. Src geo.Vec // Dst is a percentage of the bounds that the element is drawn within to use as an // anchor point. Dst geo.Vec // Offset positions the source's Anchor point at this offset relative to the destination // anchor point. Offset geo.Vec }
Anchor holds fields for positioning elements relative to each other. Center element:
Src: (0.5, 0.5) Dst: (0.5, 0.5) Offset: (0, 0)
Left align and vertically center with some padding
Src: (0, 0.5) Dst: (0, 0.5) Offset: (10, 0)
type Button ¶
type Button struct { IdleImg *ebiten.Image HoverImg *ebiten.Image Element WeightedDrawer IdleAnchor Anchor HoverAnchor Anchor Wt float64 Hover bool OnClick func() // contains filtered or unexported fields }
Button is a container that holds one sub-element and images for its states.
type Drawer ¶
Drawer provides the function Draw which draws an element to an image within a specified bounding rectangle.
type HorizontalContainer ¶
type HorizontalContainer struct { Elements []WeightedDrawer Wt float64 }
HorizontalContainer is a container that orders each of its elements horizontally. Their heights will be the full height of the bounding rectangle given to Draw and their widths will be determined by their Weights relative to the other elements.
func (*HorizontalContainer) Draw ¶
func (h *HorizontalContainer) Draw(dst *ebiten.Image, bounds geo.Rect)
Draw draws all of the container's elements to dst within bounds.
func (*HorizontalContainer) Weight ¶
func (h *HorizontalContainer) Weight() float64
Weight returns the relative weight of the container so that containers may be nested.
type Text ¶
Text is an element that contains text.
type VerticalContainer ¶
type VerticalContainer struct { Elements []WeightedDrawer Wt float64 }
VerticalContainer is a container that orders each of its elements vertically. Their widths will be the full width of the bounding rectangle given to Draw and their heights will be determined by their Weights relative to the other elements.
func (*VerticalContainer) Draw ¶
func (v *VerticalContainer) Draw(dst *ebiten.Image, bounds geo.Rect)
Draw draws all of the container's elements to dst within bounds.
func (*VerticalContainer) Weight ¶
func (v *VerticalContainer) Weight() float64
Weight returns the relative weight of the container so that containers may be nested.
type Weighted ¶
type Weighted interface {
Weight() float64
}
Weighted provides the function Weight which returns the relative space an element would like to take up.
type WeightedDrawer ¶
WeightedDrawer combines the Weighted and Drawer interfaces.