gophics

module
v0.0.0-...-91353d5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0

README

Gophics

Cross-platform native UI, written in pure Go.

One static binary on desktop and the WebGPU web — and a UI you test headlessly with go test, golden images and all.

The rendering pipeline behind the best cross-platform UIs — immutable widgets → element reconciliation → constraint layout → GPU layer compositing — reimagined with idiomatic Go APIs, on a zero-CGo WebGPU stack. It draws every pixel itself, so one codebase renders the same UI — from the same renderer — on desktop, web, iOS, and Android, and even in a terminal. No platform forks, no Dart, no JavaScript, no webview, no SDK.

Quick start · Why Gophics · A taste · Examples


Why Gophics

Gophics borrows the architecture behind the best cross-platform UIs — not their APIs — and leans into what Go does that Dart and JavaScript can't:

  • go build is the whole story. CGO_ENABLED=0 on desktop and web (mobile binds the same Go into a thin native host). One static binary per platform, cross-compiled from any OS. No SDK, no toolchain doctor, no engine artifacts to install.
  • A library, not an app framework. Gophics is a go.mod line. Pop a window from a CLI, embed a live UI inside a server, or render a widget tree straight to a PNG — headless, no display.
  • Platform services, one Go interface. File pickers, share sheets, notifications, the clipboard, secure storage, deep links, connectivity, IME, and more are plain ctx.<Cap>() calls that light up whatever the host provides and degrade cleanly where it doesn't — no #ifdef, no plugin zoo. The web implementations ship and are browser-verified today; native desktop/mobile leaves fill in per release, all zero-CGo.
  • It draws every pixel itself. A pure-Go WebGPU renderer (vendored in-tree, zero CGo) composites the UI, so it looks identical on every platform — including GPU opacity/blend layers, gradients, shadows, and real text shaping.
  • Real concurrency. Goroutines plus a single UI thread. Streaming data into a live UI — a chore in most UI stacks — is the easy case here.
  • Everything is go test. Golden-image tests, fuzzing, benchmarks, pprof — ordinary Go tooling, no emulators or bespoke harnesses.
  • No codegen in your build. Structs, generics, and the standard library. go build compiles what you wrote.
Where it fits

Most cross-platform stacks make you pick two of three. Gophics takes the corner nobody else occupies:

  • Webview wrappers — Wails, Tauri, Electron: near-single-binary, but you write JS/HTML and inherit each platform's webview quirks.
  • Native-widget bridges — React Native: real OS widgets, but a JS bridge and per-platform inconsistencies to chase.
  • Own-rendering SDKs — Flutter, Compose Multiplatform: pixel-perfect and consistent, but a whole SDK and a new language.
  • Own-rendering, but not an app toolkit — Gio, Ebitengine: the right idea in Go, but immediate-mode / game-loop, not polished widgets.

Gophics is pure Go, own-rendering, single-binary, and headless-testable — the consistency of an own-rendering toolkit, without ever leaving Go.

Quick start

go run ./examples/hello    # a colored, vsynced, resizable window
go run ./examples/todo     # a real widget app: state, taps, hover, text input
go run ./examples/hn       # a HackerNews client: feed → comments, scroll, links

Prefer a driver for the multi-platform loops? Install the CLI:

go install ./cmd/gophics

gophics run  -p desktop ./examples/notes      # native window
gophics dev  -p web     ./examples/hn          # browser, live-reload
gophics run  -p android ./examples/hn/mobile   # device/emulator (needs the SDK)
gophics create my-app                          # scaffold a new cross-platform app

A taste of the API

Widgets are plain struct values; state is a generic base you embed. Here's a full counter app:

package main

import (
	"fmt"
	"log"

	"golang.org/x/image/font/gofont/goregular"

	"github.com/doug/gophics/app"
	"github.com/doug/gophics/geom"
	"github.com/doug/gophics/theme"
	"github.com/doug/gophics/widget"
)

type Counter struct{}

func (Counter) CreateState() widget.State { return &counterState{} }

type counterState struct {
	widget.StateBase[Counter] // gives W(), SetState()
	n int
}

func (s *counterState) Build(ctx widget.Ctx) widget.Widget {
	th := theme.Auto(ctx) // follows the platform light/dark scheme
	return widget.Provide[theme.Theme]{Value: th, Child: widget.Fill{Color: th.Bg,
		Child: widget.Center(widget.Column(
			theme.Title(fmt.Sprintf("count: %d", s.n)),
			widget.Sized{H: 12},
			theme.Button{Label: "increment", Primary: true,
				OnTap: func() { s.SetState(func() { s.n++ }) }},
		)),
	}}
}

func main() {
	if err := app.Run(Counter{}, app.Config{
		Title:      "gophics counter",
		Size:       geom.Size{W: 320, H: 200},
		Background: theme.Light().Bg,
		Font:       goregular.TTF,
	}); err != nil {
		log.Fatal(err)
	}
}

Examples

Every example runs on the desktop, most compile to the browser, and all are testable headless.

Example What it shows
hello the minimal window + frame loop
todo stateful widgets, keyed reconciliation, hover animation, text input, scrolling
hn a real app: networked feed, comments, rich text/links, navigation, lazy lists
notes a local-first Markdown editor (text editing, state-as-data)
canvas the custom-paint escape hatch — draw shapes/paths/text every frame
solitaire, match3, roguelike games — drag, sprites, sound, animation
drummachine, luminaria audio synthesized in Go — a step sequencer, and a Tenori-On-style matrix instrument
telemetry 100,000 live rows: a virtualized table, charts, filter/sort, and an OpenTelemetry OTLP/JSON loader
gallery a tour of the widget catalog
mirror live camera + microphone capture, warped per-frame in a Go pixel loop
capabilities a live inspector of every platform bridge — connectivity, battery, file picker, share, notifications, clipboard, secure storage, IME, web view…

Platforms — one widget tree, everywhere

Because Gophics draws every pixel itself, the same widget tree renders the same on every target — the CPU rasterizer is the pixel-exact reference the GPU backends are held to — and it even runs in a terminal. No per-platform forks, no native-widget quirks, one design language.

Target How Status
Desktop — macOS / Linux / Windows native window, GPU-composited ✅ single static binary, zero CGo
Web — WASM WebGPU present (CPU fallback) ✅ same code, in the browser
iOS — native Metal, gomobile bind into a thin host ✅ GPU present, verified on device
Android — native Vulkan, gomobile bind into a thin host ✅ GPU present, verified on device
Terminal — incl. over SSH rendered via the kitty graphics protocol ✅ the same UI, in your terminal

The SSH demo lives in examples/ssh, which is its own module so that the SSH server dependency stays out of gophics core. That means go run ./examples/ssh from here fails with "main module does not contain package" — run it from inside instead, and connect from a terminal that speaks the kitty graphics protocol:

cd examples/ssh && go run .
ssh -p 2222 localhost          # needs a PTY; -T is refused with a hint

How it fits together

Layered like a modern UI pipeline, as Go packages (arrows point down):

widget   Widget/Element trees, State, keys, focus, reconciler, gestures (hit testing, pointer routing)
theme    design tokens & styled components (opt-in)          anim   tickers, curves, controllers
──────────────────────────────────────────────────────────────────────────────────────
layout   RenderObject protocol — constraints down, sizes up; flex/stack/padding/viewport
──────────────────────────────────────────────────────────────────────────────────────
internal/scene   retained display lists, damage tracking     paint  Canvas, paths, gradients, layers
text     shaping · bidi · line-breaking (go-text)             geom   points, rects, rrects, affine
──────────────────────────────────────────────────────────────────────────────────────
app      the runtime (app.Run · app.Headless)         shell  per-platform window/input/present
internal/gfx   the vendored pure-Go WebGPU + shader + 2D-renderer substrate (zero CGo)

Honest status

Gophics is young and moving fast — so, the real caveats up front:

  • The web binary is big. Go compiles the whole renderer into WASM, so a demo is ~5 MB gzipped. Desktop ships a lean native binary; the web is one option of a single codebase, and shrinking the web payload is a top roadmap item.
  • No hot reload, on any platform. This is Go's doing, not Apple's: -buildmode=plugin needs cgo and does not exist for android/* or ios/*, so there is no dynamic code loading to build on. What ships instead is state-preserving hot restart — rebuild, relaunch, and come back on the same screen with the same state — on desktop, web, Android and iOS. Measured: ~1.4s desktop, ~4s web, ~11s Android emulator, ~20s iOS simulator, against ~1s for a Flutter reload. Not parity, and not claimed as parity.
  • The widget catalog compounds, not complete. You compose primitives rather than assemble hundreds of pre-built widgets; the catalog grows every release.
  • Platform bridges are filling in. The capability layer — clean Go interfaces, generated wiring, graceful degradation — ships, and the web implementations are browser-verified; the native desktop/mobile leaves (objc / portals / COM / Kotlin / Swift) land incrementally. Where a bridge isn't wired yet, ctx.<Cap>() is simply nil and your UI hides the affordance — no crash, no stub dialog.
  • The API is pre-1.0. Expect breaking changes between v0.x releases while the surface settles; nothing is frozen yet, and renames land eagerly while the cost is low. The first tagged release is v0.1.0. What a v1 would cover, which fourteen packages it would cover, and how the promise is enforced are written down in COMPATIBILITY.md — proposed, so that it can be argued with before it is made.

The hard part — own-rendering pipeline, constraint layout, GPU compositing, real text shaping, four live platforms, headless golden tests, and the zero-CGo capability layer — is done.

Built on

Gophics vendors its rendering substrate in-tree (so the whole stack is one repo with zero CGo), all forks of excellent prior work — credit where it's due:

  • gg — the analytic-AA 2D renderer + tiered GPU pipeline that paint draws through (from the gogpu/gg lineage).
  • wgpu — a pure-Go WebGPU implementation (Vulkan / Metal / DX12), and naga — a pure-Go WGSL shader compiler.
  • gogpu — windowing and the higher-level GPU layer, sitting on go-webgpu/goffi + webgpu — the pure-Go FFI/dlopen floor.
  • go-text/typesetting — HarfBuzz-class shaping, bidi, and line-breaking; plus go-mp3 / oggvorbis for audio.

Every vendored tree keeps its MIT license — see THIRD_PARTY.md for the full list and attributions.

License

Gophics is licensed under the Apache License 2.0. The vendored substrate under internal/ retains its original MIT licenses (NOTICE, THIRD_PARTY.md).

Contributing

Point git at the repo's hooks once per clone:

git config core.hooksPath .githooks

That runs scripts/gates.sh before each push — gofmt, go vet, generated-code freshness, doc-embed drift and a tracked-binary size guard, about two seconds in total. CI's lint job runs the same script, so a failure here is a failure there. Run it directly any time with ./scripts/gates.sh, and bypass it in an emergency with git push --no-verify.

Some tests need a GPU and are behind a build tag, so go test ./... does not run them:

go test -tags gophics_gpu ./app/ ./paint/    # GPU-vs-CPU equivalence, blur, readback

They self-skip when no headless adapter is available. CI runs them on macOS.

CI itself is reproducible locally, which is worth doing before a push that touches build tags or platform code:

./scripts/ci-local.sh          # every job this machine can run
./scripts/ci-local.sh -l       # list the jobs and where each one runs

Linux jobs run in podman, macOS jobs natively, and the commands are read out of the workflow file rather than restated — so the runner cannot drift from CI. It catches configuration failures that go test ./... cannot see: a test file missing a build tag, a step whose env only CI sets. It does not catch architecture-specific differences, because the container is the host's architecture; see the script's header for what that misses.

Learn more

  • AGENTS.md — for coding agents (and people) changing this repo: invariants, build tags, and the traps that have actually bitten.
  • docs/ — the docs site (live demos + guides), deployed to GitHub Pages.
  • internal/capgen/ — how a platform capability is defined once in Go and wired everywhere by codegen, plus the matrix of what each platform supports.

Pure Go. Zero CGo. One codebase, every screen.

Directories

Path Synopsis
Package anim provides animation primitives: curves and controllers.
Package anim provides animation primitives: curves and controllers.
Package app ties the widget tree to a shell: the gophics runtime.
Package app ties the widget tree to a shell: the gophics runtime.
Package apptest drives a gophics UI in a test and asserts on what it produced — pixels, or the semantics tree.
Package apptest drives a gophics UI in a test and asserts on what it produced — pixels, or the semantics tree.
Package chart is a built-in, Swift Charts–style charting library: declarative marks (bars, lines, points, rules, heatmaps, ranges) composed over scales and rendered through paint.Canvas.
Package chart is a built-in, Swift Charts–style charting library: declarative marks (bars, lines, points, rules, heatmaps, ranges) composed over scales and rendered through paint.Canvas.
cmd
gophics command
Command gophics is the developer CLI for gophics apps: build, run, and hot-reload one codebase across desktop, web, terminal, and mobile.
Command gophics is the developer CLI for gophics apps: build, run, and hot-reload one codebase across desktop, web, terminal, and mobile.
docs
recipes/accessible command
Command accessible is the cookbook's accessibility recipe: a control that is drawn rather than composed, made operable and legible to assistive technology, and a decorative graphic hidden from it.
Command accessible is the cookbook's accessibility recipe: a control that is drawn rather than composed, made operable and legible to assistive technology, and a decorative graphic hidden from it.
recipes/capability command
Command capability is the cookbook's platform-capability recipe.
Command capability is the cookbook's platform-capability recipe.
recipes/custompaint command
Command custompaint is the cookbook's custom-painter recipe: a small bar chart drawn entirely inside one widget.Canvas, with its labels positioned from measured text rather than from guessed widths.
Command custompaint is the cookbook's custom-painter recipe: a small bar chart drawn entirely inside one widget.Canvas, with its labels positioned from measured text rather than from guessed widths.
recipes/gesture command
Command gesture is the cookbook's gesture recipe: one Interactive wrapping one Canvas, reporting every pointer and keyboard callback gophics offers.
Command gesture is the cookbook's gesture recipe: one Interactive wrapping one Canvas, reporting every pointer and keyboard callback gophics offers.
recipes/scrolllist command
Command scrolllist is the cookbook's scrolling-list recipe: ten thousand rows where only the visible ones are ever built, plus a controller that animates back to the top.
Command scrolllist is the cookbook's scrolling-list recipe: ten thousand rows where only the visible ones are ever built, plus a controller that animates back to the top.
recipes/selecttext command
Command selecttext is the cookbook's text-selection recipe: a passage made of three separate Text widgets that a drag selects as one continuous range, a live readout of what is selected, and a button that copies it.
Command selecttext is the cookbook's text-selection recipe: a passage made of three separate Text widgets that a drag selects as one continuous range, a live readout of what is selected, and a button that copies it.
recipes/themed command
Command themed is the cookbook's theming recipe: a brand palette derived from the built-in light and dark themes, provided to the tree, and read back by every themed component below it.
Command themed is the cookbook's theming recipe: a brand palette derived from the built-in light and dark themes, provided to the tree, and read back by every themed component below it.
recipes/transition command
Command transition is the cookbook's animation recipe.
Command transition is the cookbook's animation recipe.
tools/highlight command
Command highlight turns a Go source file into a static, syntax-highlighted HTML fragment (<pre class="code">…<span class="t-*">…</span>…</pre>), using only the standard library's go/scanner.
Command highlight turns a Go source file into a static, syntax-highlighted HTML fragment (<pre class="code">…<span class="t-*">…</span>…</pre>), using only the standard library's go/scanner.
examples
2048 command
Command 2048 is the sliding-tile puzzle: arrow keys or swipe to slide the board; equal tiles merge; reach 2048.
Command 2048 is the sliding-tile puzzle: arrow keys or swipe to slide the board; equal tiles merge; reach 2048.
canvas command
Command canvas is a generative-art demo of the widget.Canvas escape hatch.
Command canvas is a generative-art demo of the widget.Canvas escape hatch.
capabilities command
Command capabilities is a live inspector for the platform-capability layer (shell/*.go via ctx.<Cap>()): every capability the running platform exposes, shown working.
Command capabilities is a live inspector for the platform-capability layer (shell/*.go via ctx.<Cap>()): every capability the running platform exposes, shown working.
capabilities/ui
Package ui is the capability inspector's widget tree: every capability the running platform exposes, shown working, and the ones it does not expose shown greyed out.
Package ui is the capability inspector's widget tree: every capability the running platform exposes, shown working, and the ones it does not expose shown greyed out.
counter command
Command counter is the smallest complete gophics app, and the one the homepage and the getting-started guide both show.
Command counter is the smallest complete gophics app, and the one the homepage and the getting-started guide both show.
drummachine command
Command drummachine is a 16-step drum sequencer that live-synthesizes its own kick/snare/clap/hi-hat voices (no audio assets) and mixes them through the pure-Go audio engine — CoreAudio/WASAPI/PulseAudio via sound/device.
Command drummachine is a 16-step drum sequencer that live-synthesizes its own kick/snare/clap/hi-hat voices (no audio assets) and mixes them through the pure-Go audio engine — CoreAudio/WASAPI/PulseAudio via sound/device.
epub command
Command epub is a self-contained EPUB reader: it builds a small sample book as a real .epub (zip + OPF + XHTML) in memory, parses it through the full pipeline (see epub.go), and renders a typeset reader — a title page, a chapter table of contents, and a scrollable chapter view with prev/next.
Command epub is a self-contained EPUB reader: it builds a small sample book as a real .epub (zip + OPF + XHTML) in memory, parses it through the full pipeline (see epub.go), and renders a typeset reader — a title page, a chapter table of contents, and a scrollable chapter view with prev/next.
flocking command
Command flocking is Craig Reynolds' boids — the flocking sketch from Processing's examples and Nature of Code.
Command flocking is Craig Reynolds' boids — the flocking sketch from Processing's examples and Nature of Code.
flowfield command
Command flowfield is the flow-field generative-art staple (Processing, Nature of Code): a scalar field is read as an angle at every point, and particles are pushed along it, tracing the invisible field as braided streamlines.
Command flowfield is the flow-field generative-art staple (Processing, Nature of Code): a scalar field is read as an angle at every point, and particles are pushed along it, tracing the invisible field as braided streamlines.
gallery command
Command gallery is the gophics widget catalog: a sectioned, interactive showcase of the framework's higher-level components.
Command gallery is the gophics widget catalog: a sectioned, interactive showcase of the framework's higher-level components.
gallery/mobile
Package gallerymobile is the gomobile-bind surface for the widget catalog.
Package gallerymobile is the gomobile-bind surface for the widget catalog.
gallery/ui
Package ui is the gophics widget catalog: a sectioned, interactive showcase of the framework's higher-level components — controls, typography, charts, dialogs, layout primitives, implicit animations, and the Navigator/Hero/gesture stack — all built on procedural (network-free) content so it runs anywhere and stays testable headless.
Package ui is the gophics widget catalog: a sectioned, interactive showcase of the framework's higher-level components — controls, typography, charts, dialogs, layout primitives, implicit animations, and the Navigator/Hero/gesture stack — all built on procedural (network-free) content so it runs anywhere and stays testable headless.
gpucheck command
Command gpucheck runs the mobile-GPU verification scene on desktop, which is also where the desktop-GPU reference for the on-device comparison comes from (gpu_ref_test.go).
Command gpucheck runs the mobile-GPU verification scene on desktop, which is also where the desktop-GPU reference for the on-device comparison comes from (gpu_ref_test.go).
gpucheck/mobile
Package gpucheckmobile is the gomobile-bind surface for the GPU bring-up diagnostic, so it can be run on a device as itself.
Package gpucheckmobile is the gomobile-bind surface for the GPU bring-up diagnostic, so it can be run on a device as itself.
gpucheck/ui
Package gpucheck is a diagnostic scene for verifying the mobile GPU present path on a real device.
Package gpucheck is a diagnostic scene for verifying the mobile GPU present path on a real device.
health command
Command health runs the health-dashboard showcase (package healthui) on the desktop and web with the synthetic live provider.
Command health runs the health-dashboard showcase (package healthui) on the desktop and web with the synthetic live provider.
health/mobile
Package healthmobile is the gomobile-bind surface for the health app.
Package healthmobile is the gomobile-bind surface for the health app.
health/ui
Package healthui is the live health-dashboard showcase: a scrollable set of metric cards — a real-time heart rate, today's steps, weight, and sleep — each with a custom-painted chart, tappable through to a detail screen.
Package healthui is the live health-dashboard showcase: a scrollable set of metric cards — a real-time heart rate, today's steps, weight, and sleep — each with a custom-painted chart, tappable through to a detail screen.
hello command
Command hello is the minimal gophics app: a colored, vsynced, resizable window driven through the shell + paint layers (no widgets).
Command hello is the minimal gophics app: a colored, vsynced, resizable window driven through the shell + paint layers (no widgets).
hn command
Command hn is the desktop/web entry point for the HN app.
Command hn is the desktop/web entry point for the HN app.
hn/mobile
Package hnmobile is the gomobile-bind surface for the hn app.
Package hnmobile is the gomobile-bind surface for the hn app.
hn/ui
Command hn is a HackerNews client, the app that drove the scrolling, text and navigation work to completion.
Command hn is a HackerNews client, the app that drove the scrolling, text and navigation work to completion.
ledger command
Command ledger is a local-first personal-finance dashboard built on gophics, and the driver app for the built-in chart package: it renders spending, balance, and weekly-activity charts from a sample dataset (a real Ledger would import a local CSV/OFX file).
Command ledger is a local-first personal-finance dashboard built on gophics, and the driver app for the built-in chart package: it renders spending, balance, and weekly-activity charts from a sample dataset (a real Ledger would import a local CSV/OFX file).
luminaria command
Command luminaria is a generative musical instrument in the lineage of Toshio Iwai's Electroplankton and the Tenori-On: a 16×16 matrix that crawlers walk across, lighting nodes and playing them.
Command luminaria is a generative musical instrument in the lineage of Toshio Iwai's Electroplankton and the Tenori-On: a 16×16 matrix that crawlers walk across, lighting nodes and playing them.
match3 command
Command match3 is a match-3 puzzle on gophics: swap adjacent gems to line up three or more; matches clear, gems fall in to fill the gaps, and fresh gems drop from the top — chaining into cascades.
Command match3 is a match-3 puzzle on gophics: swap adjacent gems to line up three or more; matches clear, gems fall in to fill the gaps, and fresh gems drop from the top — chaining into cascades.
menus command
Command menus demonstrates the native menu bar capability.
Command menus demonstrates the native menu bar capability.
mirror command
Command mirror is a voice-reactive mirror: your camera, warped every frame by what the microphone hears.
Command mirror is a voice-reactive mirror: your camera, warped every frame by what the microphone hears.
mirror/ui
Package ui is a voice-reactive mirror: your camera, warped every frame by what the microphone hears.
Package ui is a voice-reactive mirror: your camera, warped every frame by what the microphone hears.
mover command
Command mover is a minimal real-time input demo: a square you drive with held WASD or arrow keys (and Space to dash), polling Ctx.Input() every frame.
Command mover is a minimal real-time input demo: a square you drive with held WASD or arrow keys (and Space to dash), polling Ctx.Input() every frame.
notes command
Command notes is a local-first Markdown notes app built on gophics — one codebase for desktop, web, and terminal.
Command notes is a local-first Markdown notes app built on gophics — one codebase for desktop, web, and terminal.
notes/ui
Package ui is a local-first Markdown notes app — the driving example for gophics's text-editing and state-preservation stories.
Package ui is a local-first Markdown notes app — the driving example for gophics's text-editing and state-preservation stories.
particles command
Command particles is a fountain built from a simple particle system — a burst of coloured sparks that arc under gravity and fade out, re-recorded every frame inside one widget.Canvas.
Command particles is a fountain built from a simple particle system — a burst of coloured sparks that arc under gravity and fade out, re-recorded every frame inside one widget.Canvas.
roguelike command
Command roguelike is a tile-based dungeon crawler on gophics, and the driver example for paint.DrawSprite: the whole map, monsters, and items are blitted from one procedurally-generated atlas texture (no binary assets).
Command roguelike is a tile-based dungeon crawler on gophics, and the driver example for paint.DrawSprite: the whole map, monsters, and items are blitted from one procedurally-generated atlas texture (no binary assets).
solitaire command
Command solitaire is a Klondike solitaire built on gophics — one codebase for desktop, web, and (via shell/mobile) iOS/Android.
Command solitaire is a Klondike solitaire built on gophics — one codebase for desktop, web, and (via shell/mobile) iOS/Android.
solitaire/klondike
Package klondike is the pure rules engine for Klondike solitaire: deck, piles, legal moves, an O(1) undo journal, and win detection — with no rendering, no framework imports, and no global state, so it is exhaustively unit-testable with plain `go test`.
Package klondike is the pure rules engine for Klondike solitaire: deck, piles, legal moves, an O(1) undo journal, and win detection — with no rendering, no framework imports, and no global state, so it is exhaustively unit-testable with plain `go test`.
sudoku command
Command sudoku is a full Sudoku game: tap a cell (or arrow-key to it) and type 1-9 to fill it, toggle Notes for pencil marks, and get live conflict highlighting.
Command sudoku is a full Sudoku game: tap a cell (or arrow-key to it) and type 1-9 to fill it, toggle Notes for pencil marks, and get live conflict highlighting.
telemetry command
Command telemetry is a live request explorer over a rolling window of 100,000 spans — the example for data at a scale that breaks naive UI code.
Command telemetry is a live request explorer over a rolling window of 100,000 spans — the example for data at a scale that breaks naive UI code.
todo command
Command todo is the todo example, written against the widget layer.
Command todo is the todo example, written against the widget layer.
whiteboard command
Command whiteboard is an Excalidraw-style sketchpad: a hand-drawn ("rough") shape tool set plus a smooth, variable-width freehand pen, over a toolbar with color swatches, three stroke widths, undo/redo, and clear.
Command whiteboard is an Excalidraw-style sketchpad: a hand-drawn ("rough") shape tool set plus a smooth, variable-width freehand pen, over a toolbar with color swatches, three stroke widths, undo/redo, and clear.
Package fetch makes an HTTP request without linking net/http into a browser build.
Package fetch makes an HTTP request without linking net/http into a browser build.
Package geom provides the geometric primitives used throughout gophics: points, sizes, rectangles, and edge insets.
Package geom provides the geometric primitives used throughout gophics: points, sizes, rectangles, and edge insets.
Package input is per-frame, poll-style input state for games: which keys are held right now, which were pressed/released this frame, and the pointer.
Package input is per-frame, poll-style input state for games: which keys are held right now, which were pressed/released this frame, and the pointer.
internal
apisurface
Package apisurface enumerates the module's public API, with signatures.
Package apisurface enumerates the module's public API, with signatures.
audio
Package audio provides a Pure Go audio engine for cross-platform PCM audio output, WAV decoding, and multi-channel mixing.
Package audio provides a Pure Go audio engine for cross-platform PCM audio output, WAV decoding, and multi-channel mixing.
camera
Package camera captures live video frames from the system camera.
Package camera captures live video frames from the system camera.
camera/cmd/camtest command
Command camtest opens the camera and reports what arrives — the quickest way to tell a working capture path from a plausible-looking one.
Command camtest opens the camera and reports what arrives — the quickest way to tell a working capture path from a plausible-looking one.
capgen command
Command capgen generates the platform-capability plumbing from the shell.<X>Window interfaces, so adding a capability never means hand-editing widget.Owner, the Ctx accessors, and the app-runner wiring in lockstep.
Command capgen generates the platform-capability plumbing from the shell.<X>Window interfaces, so adding a capability never means hand-editing widget.Owner, the Ctx accessors, and the app-runner wiring in lockstep.
cli
Package cli implements the gophics developer CLI.
Package cli implements the gophics developer CLI.
cli/capscan
Package capscan works out which platform capabilities an app actually reaches, so its manifest can be derived rather than remembered.
Package capscan works out which platform capabilities an app actually reaches, so its manifest can be derived rather than remembered.
dsp
Package dsp is the shared Go half of live microphone capture: level, spectrum, and a ring buffer of recent samples.
Package dsp is the shared Go half of live microphone capture: level, spectrum, and a ring buffer of recent samples.
dsp/cmd/mictest command
Command mictest is a manual check that native capture works on this machine.
Command mictest is a manual check that native capture works on this machine.
gfx/gg
Package gg provides an enterprise-grade 2D graphics library for Go.
Package gg provides an enterprise-grade 2D graphics library for Go.
gfx/gg/gpu
Package gpu registers the GPU accelerator and coverage filler for hardware-accelerated rendering.
Package gpu registers the GPU accelerator and coverage filler for hardware-accelerated rendering.
gfx/gg/integration/ggcanvas
Package ggcanvas provides seamless integration between gg 2D graphics and gogpu GPU-accelerated windows.
Package ggcanvas provides seamless integration between gg 2D graphics and gogpu GPU-accelerated windows.
gfx/gg/internal/blend
Package blend implements advanced separable and non-separable blend modes.
Package blend implements advanced separable and non-separable blend modes.
gfx/gg/internal/cache
Package cache provides generic, high-performance caching primitives.
Package cache provides generic, high-performance caching primitives.
gfx/gg/internal/clip
Package clip provides geometric clipping for paths and shapes.
Package clip provides geometric clipping for paths and shapes.
gfx/gg/internal/color
Package color provides color space types and conversions for gg.
Package color provides color space types and conversions for gg.
gfx/gg/internal/filter
Package filter provides image filter implementations for the scene graph.
Package filter provides image filter implementations for the scene graph.
gfx/gg/internal/gpu
Package gpu provides a Pure Go GPU-accelerated rendering backend using gogpu/wgpu.
Package gpu provides a Pure Go GPU-accelerated rendering backend using gogpu/wgpu.
gfx/gg/internal/gpu/tilecompute
Package tilecompute is a direct 1:1 port of Vello's CPU rasterization pipeline.
Package tilecompute is a direct 1:1 port of Vello's CPU rasterization pipeline.
gfx/gg/internal/gpucore
Package gpucore provides shared GPU abstractions for the gg rendering pipeline.
Package gpucore provides shared GPU abstractions for the gg rendering pipeline.
gfx/gg/internal/image
Package image provides image buffer management for gogpu/gg.
Package image provides image buffer management for gogpu/gg.
gfx/gg/internal/parallel
Package parallel provides tile-based parallel rendering infrastructure for gogpu/gg.
Package parallel provides tile-based parallel rendering infrastructure for gogpu/gg.
gfx/gg/internal/raster
Package raster provides CPU-based rasterization primitives for gg.
Package raster provides CPU-based rasterization primitives for gg.
gfx/gg/internal/stroke
Package stroke provides stroke expansion algorithms for converting stroked paths to filled outlines.
Package stroke provides stroke expansion algorithms for converting stroked paths to filled outlines.
gfx/gg/internal/wide
Package wide provides SIMD-friendly wide types for batch pixel processing.
Package wide provides SIMD-friendly wide types for batch pixel processing.
gfx/gg/raster
Package raster registers the CPU tile-based coverage filler for complex paths.
Package raster registers the CPU tile-based coverage filler for complex paths.
gfx/gg/recording
Package recording provides types for recording drawing operations.
Package recording provides types for recording drawing operations.
gfx/gg/recording/backends/raster
Package raster provides a raster backend for the recording system.
Package raster provides a raster backend for the recording system.
gfx/gg/render
Package render provides the integration layer between gg and GPU frameworks.
Package render provides the integration layer between gg and GPU frameworks.
gfx/gg/scene
Package scene provides blend mode integration with internal/blend package.
Package scene provides blend mode integration with internal/blend package.
gfx/gg/surface
Package surface provides a unified surface abstraction for 2D rendering.
Package surface provides a unified surface abstraction for 2D rendering.
gfx/gg/svg
Package svg provides an SVG renderer built on top of the gg 2D graphics library.
Package svg provides an SVG renderer built on top of the gg 2D graphics library.
gfx/gg/text
Package text provides GPU text rendering infrastructure.
Package text provides GPU text rendering infrastructure.
gfx/gg/text/cache
Package cache provides high-performance caching for text shaping and rendering.
Package cache provides high-performance caching for text shaping and rendering.
gfx/gg/text/emoji
Package emoji provides emoji and color font support for text rendering.
Package emoji provides emoji and color font support for text rendering.
gfx/gg/text/msdf
Package msdf provides Multi-channel Signed Distance Field generation for high-quality, scalable text rendering on GPU.
Package msdf provides Multi-channel Signed Distance Field generation for high-quality, scalable text rendering on GPU.
gfx/gogpu
Package gogpu provides a simple, cross-platform GPU graphics API for Go.
Package gogpu provides a simple, cross-platform GPU graphics API for Go.
gfx/gogpu/gmath
Package math provides vector and matrix types for gogpu.
Package math provides vector and matrix types for gogpu.
gfx/gogpu/gpu
Package gpu provides GPU types for gogpu.
Package gpu provides GPU types for gogpu.
gfx/gogpu/gpu/backend/native
Package native provides HAL backend registration for the pure Go (gogpu/wgpu) path.
Package native provides HAL backend registration for the pure Go (gogpu/wgpu) path.
gfx/gogpu/gpu/types
Package types defines GPU configuration types for gogpu.
Package types defines GPU configuration types for gogpu.
gfx/gogpu/input
Package input provides keyboard, mouse, and gamepad input handling.
Package input provides keyboard, mouse, and gamepad input handling.
gfx/gogpu/internal/platform
Minimal hand-written D-Bus session bus client.
Minimal hand-written D-Bus session bus client.
gfx/gogpu/internal/platform/darwin
Package darwin implements macOS platform support via Cocoa/AppKit.
Package darwin implements macOS platform support via Cocoa/AppKit.
gfx/gogpu/internal/platform/eventqueue
Package eventqueue provides a fixed-capacity ring buffer for platform events.
Package eventqueue provides a fixed-capacity ring buffer for platform events.
gfx/gogpu/internal/platform/wayland
Package wayland implements a pure Go Wayland client.
Package wayland implements a pure Go Wayland client.
gfx/gogpu/internal/platform/x11
Package x11 implements a pure Go X11 client for window creation.
Package x11 implements a pure Go X11 client for window creation.
gfx/gogpu/internal/platform/xkb
Package xkb provides a shared libxkbcommon wrapper for keyboard layout handling.
Package xkb provides a shared libxkbcommon wrapper for keyboard layout handling.
gfx/gogpu/internal/thread
Package thread provides thread management for GPU operations.
Package thread provides thread management for GPU operations.
gfx/gpucontext
Package gpucontext provides shared GPU infrastructure for the gogpu ecosystem.
Package gpucontext provides shared GPU infrastructure for the gogpu ecosystem.
gfx/gputypes
Package gputypes provides WebGPU type definitions for the gogpu ecosystem.
Package gputypes provides WebGPU type definitions for the gogpu ecosystem.
gfx/naga
Package naga provides a Pure Go shader compiler.
Package naga provides a Pure Go shader compiler.
gfx/naga/glsl
Package glsl provides a GLSL (OpenGL Shading Language) backend for naga.
Package glsl provides a GLSL (OpenGL Shading Language) backend for naga.
gfx/naga/internal/backend
Package backend holds cross-backend constants and helpers shared between naga's text backends (HLSL) and binary backends (DXIL) that both target the D3D ecosystem.
Package backend holds cross-backend constants and helpers shared between naga's text backends (HLSL) and binary backends (DXIL) that both target the D3D ecosystem.
gfx/naga/internal/dxcvalidator
Package dxcvalidator wraps Microsoft's IDxcValidator (dxil.dll) so naga can run real DXIL validation against generated containers from Pure Go.
Package dxcvalidator wraps Microsoft's IDxcValidator (dxil.dll) so naga can run real DXIL validation against generated containers from Pure Go.
gfx/naga/internal/dxcvalidator/bitcheck
Package bitcheck implements a minimal LLVM 3.7 bitstream reader that walks a DXIL container far enough to verify the `!dx.entryPoints` named metadata is well-formed — specifically that every entry-point tuple has a non-null function reference in operand 0.
Package bitcheck implements a minimal LLVM 3.7 bitstream reader that walks a DXIL container far enough to verify the `!dx.entryPoints` named metadata is well-formed — specifically that every entry-point tuple has a non-null function reference in operand 0.
gfx/naga/internal/registry
Package registry provides type deduplication for the naga IR.
Package registry provides type deduplication for the naga IR.
gfx/naga/internal/textutil
Package textutil provides shared text writing utilities for naga codegen backends.
Package textutil provides shared text writing utilities for naga codegen backends.
gfx/naga/ir
Package ir defines the intermediate representation for naga.
Package ir defines the intermediate representation for naga.
gfx/naga/msl
Package msl implements Metal Shading Language (MSL) code generation for naga.
Package msl implements Metal Shading Language (MSL) code generation for naga.
gfx/naga/spirv
Package spirv provides SPIR-V code generation from naga IR.
Package spirv provides SPIR-V code generation from naga IR.
gfx/naga/spirv/internal/codegen
Package codegen implements SPIR-V code generation from naga IR.
Package codegen implements SPIR-V code generation from naga IR.
gfx/naga/wgsl
Package wgsl provides WGSL (WebGPU Shading Language) parsing and lowering.
Package wgsl provides WGSL (WebGPU Shading Language) parsing and lowering.
gfx/wgpu
Package wgpu provides a safe, ergonomic WebGPU API for Go applications.
Package wgpu provides a safe, ergonomic WebGPU API for Go applications.
gfx/wgpu/core
Package core provides validation and state management for WebGPU resources.
Package core provides validation and state management for WebGPU resources.
gfx/wgpu/core/track
Package track provides resource state tracking infrastructure.
Package track provides resource state tracking infrastructure.
gfx/wgpu/hal
Package hal provides the Hardware Abstraction Layer for WebGPU implementations.
Package hal provides the Hardware Abstraction Layer for WebGPU implementations.
gfx/wgpu/hal/allbackends
Package allbackends imports all HAL backend implementations.
Package allbackends imports all HAL backend implementations.
gfx/wgpu/hal/gles
Package gles implements the HAL backend for OpenGL ES 3.0 / OpenGL 3.3+.
Package gles implements the HAL backend for OpenGL ES 3.0 / OpenGL 3.3+.
gfx/wgpu/hal/gles/egl
Package egl provides EGL (EGL) context management for OpenGL ES on Linux.
Package egl provides EGL (EGL) context management for OpenGL ES on Linux.
gfx/wgpu/hal/gles/gl
Package gl provides OpenGL constants and types for the GLES backend.
Package gl provides OpenGL constants and types for the GLES backend.
gfx/wgpu/hal/gles/wgl
Package wgl provides Windows OpenGL (WGL) context management.
Package wgl provides Windows OpenGL (WGL) context management.
gfx/wgpu/hal/metal
Package metal provides a Metal backend for the HAL.
Package metal provides a Metal backend for the HAL.
gfx/wgpu/hal/noop
Package noop provides a no-operation GPU backend.
Package noop provides a no-operation GPU backend.
gfx/wgpu/hal/software
FFI error handling follows ADR-049 three-tier strategy:
FFI error handling follows ADR-049 three-tier strategy:
gfx/wgpu/hal/software/raster
Package raster provides CPU-based triangle rasterization for the software backend.
Package raster provides CPU-based triangle rasterization for the software backend.
gfx/wgpu/hal/software/shader
Package shader provides shader execution for the software backend.
Package shader provides shader execution for the software backend.
gfx/wgpu/hal/vulkan
Package vulkan provides Pure Go Vulkan backend for the HAL.
Package vulkan provides Pure Go Vulkan backend for the HAL.
gfx/wgpu/hal/vulkan/memory
Package memory provides GPU memory allocation for Vulkan backend.
Package memory provides GPU memory allocation for Vulkan backend.
gfx/wgpu/hal/vulkan/vk
Package vk provides Pure Go Vulkan bindings using goffi for FFI calls.
Package vk provides Pure Go Vulkan bindings using goffi for FFI calls.
gfx/wgpu/internal/indirect
Package indirect provides overflow-safe arithmetic for indirect draw spans.
Package indirect provides overflow-safe arithmetic for indirect draw spans.
gfx/wgpu/internal/thread
Package thread provides thread abstraction for GPU operations.
Package thread provides thread abstraction for GPU operations.
layoutbox
Package layoutbox holds the render-object implementations behind the widget layer: the concrete layout.Box types a widget builds, plus the inspector helpers.
Package layoutbox holds the render-object implementations behind the widget layer: the concrete layout.Box types a widget builds, plus the inspector helpers.
menubar
Package menubar is the meeting point between a desktop shell and the app runner for a menu bar the app has to draw itself.
Package menubar is the meeting point between a desktop shell and the app runner for a menu bar the app has to draw itself.
objc
Package objc is a minimal Objective-C runtime bridge for the shell layer's macOS capability implementations (file dialogs, share sheets, notifications).
Package objc is a minimal Objective-C runtime bridge for the shell layer's macOS capability implementations (file dialogs, share sheets, notifications).
prefs
Package prefs is the JSON-file preferences store shared by every shell that has a filesystem.
Package prefs is the JSON-file preferences store shared by every shell that has a filesystem.
renderref
Package renderref is a shared reference scene for the render-correctness harness: one widget that exercises every paint primitive, with content deliberately reaching all four quadrants (including the bottom-right corner) and inside clip/opacity/transform groups.
Package renderref is a shared reference scene for the render-correctness harness: one widget that exercises every paint primitive, with content deliberately reaching all four quadrants (including the bottom-right corner) and inside clip/opacity/transform groups.
scene
Package scene provides display lists: recorded paint commands that can be replayed onto any paint.Canvas.
Package scene provides display lists: recorded paint commands that can be replayed onto any paint.Canvas.
testfont
Package testfont derives small test fonts from a real one, for exercising the font fallback chain without shipping a fixture file.
Package testfont derives small test fonts from a real one, for exercising the font fallback chain without shipping a fixture file.
wav
Package intl formats numbers, money and dates the way a reader's locale writes them: 1,234.56 in the US, 1.234,56 in Germany, 1 234,56 in France, 12,34,567.89 in India.
Package intl formats numbers, money and dates the way a reader's locale writes them: 1,234.56 in the US, 1.234,56 in Germany, 1 234,56 in France, 12,34,567.89 in India.
cmd/gophics-intl command
Command gophics-intl extracts translatable messages from Go source into a catalog file that intl.ReadJSON loads.
Command gophics-intl extracts translatable messages from Go source into a catalog file that intl.ReadJSON loads.
internal/extract
Package extract finds translatable messages in Go source and turns them into a catalog stub.
Package extract finds translatable messages in Go source and turns them into a catalog stub.
Package layout is gophics's render-layer protocol: the Box interface, the constraints that flow through it, hit testing, and semantics.
Package layout is gophics's render-layer protocol: the Box interface, the constraints that flow through it, hit testing, and semantics.
Package paint provides gophics's drawing layer.
Package paint provides gophics's drawing layer.
Package shell defines the platform interface gophics runs on: a Window (or surface) that delivers input Events and vsync-paced Frames to a Handler, with each Frame exposing a presentation Target (GPU texture view or pixel sink) that the framework renders into.
Package shell defines the platform interface gophics runs on: a Window (or surface) that delivers input Events and vsync-paced Frames to a Handler, with each Frame exposing a presentation Target (GPU texture view or pixel sink) that the framework renders into.
desktop
Desktop implementation of the accessibility capability (shell/a11y.go).
Desktop implementation of the accessibility capability (shell/a11y.go).
mobile
Package mobile implements shell for embedded hosts (Android/iOS): the host platform owns the surface and event loop and drives a Bridge — pushing input in, presenting frames out.
Package mobile implements shell for embedded hosts (Android/iOS): the host platform owns the surface and event loop and drives a Bridge — pushing input in, presenting frames out.
terminal
Terminal implementation of the preferences capability (shell/prefs.go).
Terminal implementation of the preferences capability (shell/prefs.go).
web
skills
gophics/apicheck
Package apicheck is a compile-time contract for the gophics skill.
Package apicheck is a compile-time contract for the gophics skill.
gophics/examples/counter command
Command counter is the canonical minimal gophics app referenced by SKILL.md: a stateful widget whose state is mutated through SetState.
Command counter is the canonical minimal gophics app referenced by SKILL.md: a stateful widget whose state is mutated through SetState.
gophics/examples/customdraw command
Command customdraw is the SKILL.md custom-painting example: a *stateless* widget (Build only, no mutable state) that draws a small bar chart through widget.Canvas + paint.Canvas — the escape hatch for graphics that don't decompose into widgets.
Command customdraw is the SKILL.md custom-painting example: a *stateless* widget (Build only, no mutable state) that draws a small bar chart through widget.Canvas + paint.Canvas — the escape hatch for graphics that don't decompose into widgets.
Package sound is a pure-Go DSP mixer for game and UI audio: PCM samples, oscillators, gain, and a mixer that a platform sink pulls from.
Package sound is a pure-Go DSP mixer for game and UI audio: PCM samples, oscillators, gain, and a mixer that a platform sink pulls from.
device
Package device connects a sound.Mixer to the platform's audio output using the doug/audio drivers (CoreAudio / PulseAudio / WASAPI / WebAudio).
Package device connects a sound.Mixer to the platform's audio output using the doug/audio drivers (CoreAudio / PulseAudio / WASAPI / WebAudio).
mp3
Package mp3 decodes MP3 audio into a sound.Sample.
Package mp3 decodes MP3 audio into a sound.Sample.
ogg
Package ogg decodes Ogg Vorbis audio into a sound.Sample.
Package ogg decodes Ogg Vorbis audio into a sound.Sample.
pitch
Package pitch estimates the fundamental frequency of monophonic audio — a sung or played note — and names it musically.
Package pitch estimates the fundamental frequency of monophonic audio — a sung or played note — and names it musically.
procedural
Package procedural synthesizes small sound effects and ambient music in Go — no audio assets, matching the framework's "generate it in code" grain.
Package procedural synthesizes small sound effects and ambient music in Go — no audio assets, matching the framework's "generate it in code" grain.
Package text is gophics's text stack: shaping, bidi, font fallback, and line breaking, built on go-text/typesetting (the shared pure-Go HarfBuzz-family stack used by Gio, Fyne, and Ebitengine).
Package text is gophics's text stack: shaping, bidi, font fallback, and line breaking, built on go-text/typesetting (the shared pure-Go HarfBuzz-family stack used by Gio, Fyne, and Ebitengine).
Package theme is gophics's default design language: a Theme value provided to the tree plus components pre-wired to consult it.
Package theme is gophics's default design language: a Theme value provided to the tree plus components pre-wired to consult it.
tools
uitrace command
Command uitrace replays a scroll gesture through gophics and writes what the scroll view did with it: a trace, a CSV, metrics, and optionally the frames and a video.
Command uitrace replays a scroll gesture through gophics and writes what the scroll view did with it: a trace, a CSV, metrics, and optionally the frames and a video.
uitrace/trace
Package trace is the shared record of one scroll gesture and what a scroll view did with it — the contract between gophics and a native twin.
Package trace is the shared record of one scroll gesture and what a scroll view did with it — the contract between gophics and a native twin.
Package widget implements gophics's declarative layer: immutable widget values describing the UI, reconciled into a retained element tree that owns layout boxes.
Package widget implements gophics's declarative layer: immutable widget values describing the UI, reconciled into a retained element tree that owns layout boxes.

Jump to

Keyboard shortcuts

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