A simple Framework based on Raylib using GO Bindings and Flex, a CSS flexbox layout implementation in Go.
Flex and raylib-goplus are required:
$ go get github.com/kjk/flex
$ go get github.com/lachee/raylib-goplus/raylib
On Linux, xorg-dev must be installed:
$ apt-get install xorg-dev
package main
import (
"github.com/Slixe/visual-go/app""github.com/Slixe/visual-go/components""github.com/Slixe/visual-go/graphics""github.com/Slixe/visual-go/panels""github.com/Slixe/visual-go/structures""github.com/kjk/flex"
rl "github.com/lachee/raylib-goplus/raylib"
)
funcmain() {
window:= app.App{
Title: "Hello World",
Width: 780,
Height: 640,
ScrollSpeed: 20,
Resizable: true,
DrawFPS: true,
DefaultColor: rl.GopherBlue,
Flex: app.Flex{
Direction: flex.DirectionLTR,
},
}
window.Start() //start applicationfont:=*window.GetFont()//get default fontmainLayout:=window.NewLayout() //create global layoutmainLayout.StyleSetFlexGrow(1)
fontSize:=float32(42)
spacing:=float32(0)
panel:=panels.CreateColoredPanel(rl.White) //create colored panelmsg:="Hello World!"msgSize:=graphics.MeasureText(font, msg, fontSize, spacing) //measure text sizepanel.AddComponent(components.CreateText(font, msg, rl.Black, func(g structures.IGraphics, app structures.IApp) structures.Vector4f {
returngraphics.Position((g.GetWidth() -msgSize.X) /2, (g.GetHeight() -msgSize.Y) /2, msgSize.X, msgSize.Y)
}, fontSize, spacing))
window.RegisterLayout("global", mainLayout) //register our layoutwindow.SetPanel("global", panel) //set panel using global layoutwindow.Render() //start rendering
}
