gui

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Background = color.RGBA{R: 18, G: 20, B: 26, A: 255}

Background is the colour behind every frame. The caller clears with it, since how you clear differs between a live window and a pixel buffer.

Functions

func Available

func Available() bool

func DrawFrame added in v0.4.0

func DrawFrame(r core.Renderer, cfg Config, st FrameState)

DrawFrame composes one frame — the world, the sensor rays, the HUD, the keymap and the fitness sparkline — through r. It draws only through core.Renderer, so the same code composes a live window frame and a headless one for documentation media. The caller clears to Background first.

func Render added in v0.4.0

func Render(cfg Config, log *slog.Logger) error

Render records a run to cfg.Rec.Path without opening a window, drawing every frame through the software renderer. It composes frames with the same DrawFrame the window uses, so the media matches what a player sees, and it needs no display — a docs build can run it anywhere.

The file extension picks the format: .gif or .mp4.

func Run

func Run(_ Config, _ *slog.Logger) error

Types

type Config

type Config struct {
	Title      string
	Keymap     []keymap.Binding
	Population bool

	Step     func() bool
	Complete func()
	Next     func()
	Render   func(core.Renderer)
	HUD      func() []string
	Series   func() []float64

	Bounds  func() (minX, minY, maxX, maxY float64, ok bool)
	Leader  func() (x, y float64, ok bool)
	Sensors func() (origin core.Vec2, ends []core.Vec2, ok bool)

	Save       func() error
	Load       func() error
	Regenerate func(seed int64)

	// Rec names the recording [Render] writes; it is set by tools/demogen.
	Rec record.Options
}

type FrameState added in v0.4.0

type FrameState struct {
	Speed    int
	Paused   bool
	Elapsed  time.Duration
	ShowRays bool
	Follow   bool
}

FrameState is the view state that belongs to the run rather than the world: how fast it is going, whether it is paused, and what extras are shown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL