Debug

PrintAt

You can print to the screen with the following:

1func PrintAt(s string, x int, y int, c color.Color)

Example

 1package main
 2
 3import (
 4	"github.com/dfirebaugh/hlg"
 5	"golang.org/x/image/colornames"
 6)
 7
 8func update() {
 9	hlg.Clear(colornames.Grey)
10	hlg.PrintAt("hello, world", 10, 30, colornames.Red)
11}
12
13func main() {
14	hlg.SetWindowSize(200, 200)
15	hlg.Update(update)
16}

FPS

To see the current FPS (frames per second), you can call this function

1func GetFPS() float64

To show the fps in the window title, you can enable it with:

1hlg.EnableFPS()

Example

 1package main
 2
 3import (
 4	"fmt"
 5
 6	"github.com/dfirebaugh/hlg"
 7	"golang.org/x/image/colornames"
 8)
 9
10func main() {
11	hlg.SetWindowSize(720, 480)
12	hlg.SetScreenSize(240, 160)
13	t := hlg.Triangle(0, 160, 120, 0, 240, 160, colornames.Orangered)
14
15	hlg.EnableFPS()
16
17	hlg.Update(func() {
18		hlg.Clear(colornames.Skyblue)
19		t.Render()
20		hlg.PrintAt("hello, world", 10, 30, colornames.Red)
21		hlg.PrintAt(fmt.Sprintf("%f", hlg.GetFPS()), 10, 50, colornames.Red)
22	})
23}

debug_example