recording

command
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 5 Imported by: 0

README

Recording System Example

This example demonstrates the recording system for vector export.

What it does

  1. Creates a Recorder to capture drawing operations
  2. Draws various shapes: gradient background, circle, rounded rectangle, dashed line, rotated square
  3. Exports to multiple formats: PNG (raster), PDF, SVG

Running

Raster only (no additional dependencies)
go run main.go

Output: output.png

With PDF export
go get github.com/gogpu/gg-pdf

Then uncomment the import in main.go:

_ "github.com/gogpu/gg-pdf"

Output: output.png, output.pdf

With SVG export
go get github.com/gogpu/gg-svg

Then uncomment the import in main.go:

_ "github.com/gogpu/gg-svg"

Output: output.png, output.svg

Key Concepts

Recording
rec := recording.NewRecorder(width, height)
// Draw using familiar API...
r := rec.Finish()
Playback
backend, _ := recording.NewBackend("pdf")
r.Playback(backend)
backend.(recording.FileBackend).SaveToFile("output.pdf")
Backend Registration

Backends are registered via blank imports (like database/sql drivers):

import _ "github.com/gogpu/gg-pdf"  // Registers "pdf"
import _ "github.com/gogpu/gg-svg"  // Registers "svg"

Output

The example produces a 400x300 image with:

  • Gradient background (dark blue to light blue)
  • Red circle
  • White rounded rectangle (stroked)
  • Yellow dashed line
  • Green rotated square with transparency

Documentation

Overview

Example: Recording System

This example demonstrates the recording system for vector export. It creates a drawing, records it, and exports to multiple formats.

To run with PDF/SVG export, you need the backend packages:

go get github.com/gogpu/gg-pdf
go get github.com/gogpu/gg-svg

Then uncomment the relevant import lines below.

Jump to

Keyboard shortcuts

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