Package gfx provides a simple native Go 2d graphics library for Windows and Linux.
Use the 'go' command:
$ go get github.com/taylorza/go-gfx
package main
import (
"github.com/taylorza/go-gfx/pkg/gfx"
)
// Define a type that represents your application. This type must satisfy the Application interface
// and provide the Load, Update and Unload methods. This struct can maintain any additional state you
// require for your graphics application
type myapp struct {
}
// Load called once when the application is initialized
func (app *myapp) Load() {}
// Unload called when the application ends
func (app *myapp) Unload() {}
// Update called for every frame and provides the time in seconds since the last frame update
func (app *myapp) Update(delta float64) {
// Update and draw your frame
gfx.Clear(gfx.Cyan)
gfx.DrawCircle(gfx.Width()/2, gfx.Height()/2, gfx.Height()/3, gfx.Red)
}
func main() {
if gfx.Init("GFX Example", 0, 0, 320, 240, 2, 2) {
gfx.Run(&myapp{})
}
}