gui

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() bool

func DrawScene added in v0.4.0

func DrawScene(c *canvas.Canvas, g SceneView)

DrawScene composes a whole frame onto c — every cube, the grid chrome, the status line, the control hints and the move list. Drawing through the software canvas rather than the display means the same code paints a live window and a headless recording, pixel for pixel.

func Render added in v0.4.0

func Render(cfg Config) error

Render records a scripted run to cfg.Rec.Path without opening a window. It drives the same [gameState] the window drives, replaying cfg.Keys as if a player had pressed them, and composes frames with the same DrawScene — so the media matches what a player sees and needs no display.

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

func Run added in v0.1.1

func Run(cfg Config) error

Types

type Cell

type Cell struct {
	Strategy string
	Initial  cube.Cube
	Label    string
}

type Config added in v0.1.1

type Config struct {
	Controller Controller
	Link       *Link

	// Rec names the recording [Render] writes and Keys is the comma-separated
	// keybind script it replays (e.g. "space", "shift+up", "plus,plus,tab").
	// tools/demogen sets both; the window uses neither.
	Rec  record.Options
	Keys string
}

type Controller

type Controller struct {
	Strategies []string
	Start      int
	Initial    *cube.Cube
	Scramble   func() cube.Cube

	Solve func(strategy string, c cube.Cube) (moves []cube.Move, solved bool)

	Title       string
	OffsetIndex int
}

type CubeView added in v0.4.0

type CubeView struct {
	Facelets  cube.Facelets
	Label     string
	Status    string
	Short     string
	Turning   bool
	TurnMove  cube.Move
	TurnFrame int
	Idx       int
	Moves     []cube.Move
}

CubeView is one cube's drawable state.

type Link = hub.Link[Msg]

Link is the window's channel pair to the multi-window hub. It aliases the engine's generic hub link specialised to Msg, so the leader and child wiring in internal/cli can hand the window a hub.Link[Msg] directly.

type Msg added in v0.1.0

type Msg struct {
	Type      string  `json:"t"`
	Yaw       float32 `json:"yaw,omitempty"`
	Pitch     float32 `json:"pitch,omitempty"`
	Zoom      float32 `json:"zoom,omitempty"`
	UnfoldTo  float32 `json:"unfoldTo,omitempty"`
	Xray      bool    `json:"xray,omitempty"`
	ShowMoves bool    `json:"showMoves,omitempty"`
}

type SceneView added in v0.4.0

type SceneView struct {
	Cubes                    []CubeView
	Cols, Rows, W, H, Focus  int
	Yaw, Pitch, Zoom, Unfold float32
	Xray, Manual, ShowMoves  bool
	Grid                     bool
	Polys                    []render.Poly
}

SceneView is everything a frame draws, lifted out of the windowed game state so the composer needs nothing from the display.

Jump to

Keyboard shortcuts

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