go-gfx

The pure-Go 2D graphics foundation. One substrate, many renderers.

go-gfx is the pure-Go, cgo-free layer that sits below the fleet's image-processing and rendering libraries — the Go answer to what Skia, Cairo and image/draw provide elsewhere. Pixel buffers, colour science, high-quality resampling, image codecs and a vector rasterizer, each usable on its own, with no third-party dependencies.

It is not an image-processing library (that is go-images, the scikit-image analogue) and not a widget toolkit (that is go-widgets). It is the common layer both stand on, so colour blending, resampling, codecs and path rasterization are written and tested once and shared across the whole ecosystem.

Pure Go CGO=0 Zero dependencies 6 architectures BSD-3-Clause

Why go-gfx

2D graphics in most languages means binding a C engine — Skia, Cairo, Pixman. Across the Go fleet, several libraries had each grown their own copy of the same primitives: an image processor resampling pixels, a widget toolkit rasterizing vector paths, a web engine decoding image codecs, a desktop stack rendering icons. go-gfx extracts that shared substrate into one pure-Go, cgo-free module so colour blending, resampling, codecs and path rasterization are written and tested once. It follows the Skia / Cairo / image/draw layering: a foundation below, many renderers on top. It depends on nothing fleet-side except go-asmgen for optional SIMD, and it cross-compiles to a static binary on every 64-bit target.

Packages

A single Go module, github.com/go-gfx/gfx, split into focused packages — import only what you need.

geometry

Points, rectangles and affine transforms — the coordinate math shared by every layer: translate, scale, rotate, shear, compose and invert.

color

Colour science: RGB / XYZ / Lab, sRGB↔linear conversion, premultiplied alpha, and Porter-Duff / separable blend modes done correctly in linear light.

raster

The shared pixel-buffer and pixel-format substrate — the common image surface every consumer reads and writes, with format conversions between them.

resample

High-quality resizing: box / area averaging, bicubic (Catmull-Rom) and Lanczos, separable and weight-precomputed, validated against reference implementations.

codec

Image decoders and encoders — PNG, JPEG, WebP, ICO, ICNS, GIF, TIFF — one shared set that subsumes the codecs each consumer used to hand-roll.

vector

Paths, an anti-aliased scanline rasterizer, strokes and gradients — the 2D vector engine renderers build on instead of rolling their own.

Consumers

go-gfx is a foundation: it is meant to be depended on. These fleet libraries build on it instead of each re-implementing the same primitives.

go-images

The scikit-image-style image-processing library. Filters, edges and morphology built on raster, color and resample.

go-widgets/painter

The tri-backend widget renderer. Path fills, strokes and gradients built on vector, raster and color.

go-webengine

The headless HTML/CSS → image engine (no Chromium). Layout painting built on resample, codec and vector.

go-widgets/desktop

The desktop shell. Icon and thumbnail rendering built on codec and resample, replacing hand-rolled ICNS/ICO decoders.

Quality bar