holy shit components are rendering whaaaaaaaaaaaaaaaat
This commit is contained in:
62
tools/component_test/editor.go
Normal file
62
tools/component_test/editor.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"git.vezzani.net/ben/games/common/elements/v1"
|
||||
"git.vezzani.net/ben/games/common/elements/v1/blocks"
|
||||
"git.vezzani.net/ben/games/common/elements/v1/stacks"
|
||||
"git.vezzani.net/ben/games/common/sprites/v1"
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
"golang.org/x/image/colornames"
|
||||
)
|
||||
|
||||
var menu = stacks.New(
|
||||
stacks.Horizontal(),
|
||||
stacks.BlockOpt(blocks.BackgroundColor(color.White)),
|
||||
stacks.BlockOpt(blocks.Size(200, 200)),
|
||||
stacks.BlockOpt(blocks.Name("parent")),
|
||||
stacks.Children(
|
||||
stacks.New(
|
||||
stacks.BlockOpt(blocks.Name("left")),
|
||||
stacks.Children(
|
||||
blocks.New(blocks.BackgroundColor(colornames.Green)),
|
||||
blocks.New(blocks.BackgroundColor(colornames.Yellow)),
|
||||
)),
|
||||
stacks.New(
|
||||
stacks.BlockOpt(blocks.Name("right")),
|
||||
stacks.Children(
|
||||
blocks.New(blocks.BackgroundColor(colornames.Blue)),
|
||||
blocks.New(blocks.BackgroundColor(colornames.Red)),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
func newEditor() *editor {
|
||||
return &editor{}
|
||||
}
|
||||
|
||||
type editor struct {
|
||||
}
|
||||
|
||||
func (e *editor) Update() error {
|
||||
sprites.Update()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *editor) Draw(screen *ebiten.Image) {
|
||||
b := screen.Bounds()
|
||||
menu(elements.Dimensions{
|
||||
ZX: float64(b.Min.X),
|
||||
ZY: float64(b.Min.Y),
|
||||
WX: float64(b.Max.X),
|
||||
WY: float64(b.Max.Y),
|
||||
}).Draw(screen)
|
||||
//panic("done")
|
||||
}
|
||||
|
||||
func (e *editor) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
|
||||
return outsideWidth, outsideHeight
|
||||
}
|
||||
Reference in New Issue
Block a user