Skip to content

Slixe/visual-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Visual GO

A simple Framework based on Raylib using GO Bindings and Flex, a CSS flexbox layout implementation in Go.

How to start

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

Example:

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"
)

func main() {
	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 application

	font := *window.GetFont()//get default font
	mainLayout := window.NewLayout() //create global layout
	mainLayout.StyleSetFlexGrow(1)
	fontSize := float32(42)
	spacing := float32(0)

	panel := panels.CreateColoredPanel(rl.White) //create colored panel
	msg := "Hello World!"
	msgSize := graphics.MeasureText(font, msg, fontSize, spacing) //measure text size

	panel.AddComponent(components.CreateText(font, msg, rl.Black, func(g structures.IGraphics, app structures.IApp) structures.Vector4f {
		return graphics.Position((g.GetWidth() - msgSize.X) / 2, (g.GetHeight() - msgSize.Y) / 2, msgSize.X, msgSize.Y)
	}, fontSize, spacing))

	window.RegisterLayout("global", mainLayout) //register our layout
	window.SetPanel("global", panel) //set panel using global layout
	window.Render() //start rendering
}

Scaling Example

scale example

Animation Example

Animation example

About

Go Framework to create simple application using Raylib & Flex

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages