Join the Discussion: Help shape the future of Go graphics! Share your ideas, report issues, and discuss features at our GitHub Discussions.
Update (December 2025): gogpu/gg v0.14.0 released! Alpha masks, fluent PathBuilder, streaming I/O, and io.Closer support. Part of the 214K LOC Pure Go ecosystem.
When I discovered that fogleman/gg — the beloved 2D graphics library for Go — hadn't been updated since 2019, I knew the Go community needed a successor. Today, I'm excited to announce gogpu/gg v0.14.0 — a modern, GPU-accelerated 2D graphics library inspired by fogleman/gg.
The Journey
It all started with a Reddit discussion about the state of graphics and GUI development in Go. The community's frustration was clear: Go deserves better graphics support.
So we built it.
What is gogpu/gg?
gogpu/gg is a Pure Go 2D graphics library designed for:
- IDEs (GoLand, VS Code level performance)
- Browsers (Chrome-level rendering)
- Professional graphics applications
Key Features
| Feature | Description |
|---|---|
| Similar API | Easy migration from fogleman/gg |
| Pure Go | Zero CGO, simple go build
|
| GPU Acceleration | WebGPU via Sparse Strips algorithm |
| Scene Graph | Retained mode with dirty region tracking |
| Layers | Per-layer opacity and transformations |
| Alpha Masks | Compositing masks for advanced effects (v0.14.0) |
| 29 Blend Modes | Porter-Duff + Advanced + HSL |
| Fluent PathBuilder | Method chaining for path construction (v0.14.0) |
| Streaming I/O |
EncodePNG(w io.Writer) for any output (v0.14.0) |
| Parallel Rendering | TileGrid + WorkerPool |
| LUT Optimizations | 260x faster sRGB conversions |
Quick Start
package main
import (
"github.com/gogpu/gg"
"github.com/gogpu/gg/text"
)
func main() {
ctx := gg.NewContext(512, 512)
ctx.ClearWithColor(gg.White)
// Draw shapes
ctx.SetColor(gg.Hex("#3498db"))
ctx.DrawCircle(256, 256, 100)
ctx.Fill()
// Load font and draw text
source, _ := text.NewFontSourceFromFile("arial.ttf")
defer source.Close()
ctx.SetFont(source.Face(32))
ctx.SetColor(gg.Black)
ctx.DrawString("Hello, GoGPU!", 180, 260)
ctx.SavePNG("output.png")
}
Fluent PathBuilder (v0.14.0)
// Method chaining for complex paths
path := gg.BuildPath().
Circle(100, 100, 50).
Star(200, 100, 40, 20, 5).
RoundedRect(50, 150, 100, 80, 10).
Build()
ctx.SetColor(gg.Hex("#e74c3c"))
ctx.DrawPath(path)
ctx.Fill()
Architecture: Sparse Strips
GPU acceleration uses the Sparse Strips algorithm — the same approach used by vello:
Path → CPU Tessellation → Strips → GPU Rasterization → Compositing
- CPU handles complex path math (curves, intersections)
- GPU handles parallel pixel processing
- Minimal data transfer (strips are compact)
The GoGPU Ecosystem
gogpu/gg is part of a larger Pure Go GPU Computing Ecosystem:
| Project | Description | Version | LOC |
|---|---|---|---|
| gogpu/gg | 2D graphics library | v0.14.0 | ~95K |
| gogpu/gogpu | Graphics framework | v0.8.0 | ~26K |
| gogpu/wgpu | Pure Go WebGPU | v0.7.0 | ~71K |
| gogpu/naga | Shader compiler (WGSL→SPIR-V/MSL/GLSL) | v0.6.0 | ~23K |
| gogpu/ui | GUI widget toolkit | Planning | — |
Total: ~214K lines of Pure Go — no CGO, no Rust, no C.
wgpu Backends
The Pure Go WebGPU implementation supports multiple backends:
| Backend | Status | Use Case |
|---|---|---|
| Vulkan | ✅ Done | Cross-platform (Windows/Linux/macOS) |
| Metal | ✅ Done | macOS/iOS |
| OpenGL ES | ✅ Done | Windows + Linux |
| Software | ✅ Done | Headless, CI/CD, no GPU required |
| DX12 | Planned | Windows native |
Version History
| Version | Milestone |
|---|---|
| v0.1.0 | Canvas API, shapes, paths |
| v0.2.0 | Text rendering (FontSource/Face) |
| v0.3.0 | Images, clipping, compositing |
| v0.4.0 | Color pipeline, layer API |
| v0.5.0 | LUT optimization (260x faster sRGB) |
| v0.6.0 | Parallel rendering |
| v0.7.0 | Scene graph (retained mode) |
| v0.8.0 | Backend abstraction |
| v0.9.0 | GPU acceleration |
| v0.10.0 | Gradient rendering, arc improvements |
| v0.11.0 | Path operations, boolean ops |
| v0.12.0 | Transform stack, clip regions |
| v0.13.0 | Advanced text layout |
| v0.14.0 | Alpha masks, fluent PathBuilder, streaming I/O |
What's Next?
- v0.15.0: GPU text rendering (glyph atlas, SDF fonts)
- v1.0.0: Production release with stable API
- gogpu/ui: Signals-based GUI toolkit (in planning)
Acknowledgments
Special thanks to:
- @fogleman for the original gg that inspired this project
- The vello team for Sparse Strips research
- The Go community on r/golang
Links
- GitHub: https://github.com/gogpu/gg
- GoGPU Organization: https://github.com/gogpu
- Discussion: Join the conversation
- v0.14.0 Release: gogpu/gg v0.14.0
Star the repo if you find it useful! Contributions welcome.
go get github.com/gogpu/gg@v0.14.0
Top comments (0)