gfx

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: BSD-3-Clause Imports: 0 Imported by: 0

README

gfx — pure-Go 2D graphics foundation

github.com/go-gfx/gfx is a pure-Go, CGO=0 2D graphics foundation: the shared substrate that sits below the fleet's image-processing and rendering libraries.

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: pixel buffers, colour science, high-quality resampling, image codecs, and vector rasterization — each usable on its own, with no third-party dependencies.

Packages

Package Purpose
geometry points, rectangles, affine transforms
color full colour science: HSV/HSL/HWB, XYZ/Lab/LCh/Luv/OKLab/OKLCH, Y′CbCr, CMYK, D65↔D50 Bradford, ΔE (76/94/2000/OK), separable + non-separable blends, premultiplied alpha
raster shared pixel-buffer / pixel-format substrate
resample high-quality resizing: box/area, bicubic (Catmull-Rom), Lanczos
codec image decoders/encoders: png, jpeg, webp, ico, icns, gif, tiff
vector paths, anti-aliased fill/stroke rasterizer (round joins & caps, non-zero / even-odd), linear/radial gradients, source-over compositing

Consumers

  • go-images — image processing/analysis, built on raster/color/resample.
  • go-widgets/painter — tri-backend renderer, built on vector/raster/color.
  • go-webengine — HTML/CSS → image, built on resample/codec/vector.
  • go-widgets/desktop — icon & thumbnail rendering.

Status

Landed: geometry (float64 point / axis-aligned rect / 2-D affine matrix — translate, scale, rotate, shear, compose, invert, transform point & rect), raster (pixel substrate), color (a complete colour-science layer: premultiplied alpha; the sRGB and generic-gamma transfer functions; the cylindrical sRGB models HSV/HSL/HWB; the CIE hub XYZ with D65 and D50 white points and Bradford D65↔D50 adaptation; CIE L*a*b*/LCh, L*u*v*/LCh(uv), Ottosson OKLab/OKLCH; Y′CbCr BT.601/709 and naive CMYK; the ΔE colour-difference metrics ΔE76, ΔE94, CIEDE2000 and ΔE-OK; the W3C separable and non-separable blend modes; and a second, scikit-image-byte-compatible sRGB↔XYZ↔Lab regime so go-images can share one colour library — all numerically checked against the colour-science oracle and the published CIE / W3C / Sharma reference values), resample (nearest, bilinear, box/area, bicubic, Lanczos — each with a premultiplied-alpha variant), and vector (2-D path builder + anti-aliased scanline fill/stroke rasterizer, extracted verbatim from go-widgets/painter and proven pixel-identical to it, now with linear/radial gradients and source-over compositing of any paint through a coverage grid). Colour-science and blend results match the published CIE / W3C reference values. Pure-Go, CGO=0, 100% covered, six-arch CI, numeric parity with Pillow. See docs/perf.md.

License

BSD-3-Clause — see LICENSE. Copyright the go-gfx authors.

Documentation

Overview

Package gfx is the module root for the go-gfx pure-Go 2D graphics foundation.

The functionality lives in subpackages (geometry, color, raster, resample, codec, vector). This file exists only to document the module and give it a root package; import the subpackage you need.

Directories

Path Synopsis
Package codec is go-gfx's unified image-decoding registry: one Decode entry point that sniffs a byte slice's container format and dispatches to the appropriate REFERENCE decoder, returning the shared raster.Image substrate the rest of go-gfx consumes.
Package codec is go-gfx's unified image-decoding registry: one Decode entry point that sniffs a byte slice's container format and dispatches to the appropriate REFERENCE decoder, returning the shared raster.Image substrate the rest of go-gfx consumes.
Package color holds go-gfx's colour helpers.
Package color holds go-gfx's colour helpers.
Package geometry is go-gfx's floating-point 2-D geometry substrate: a Point, an axis-aligned Rect, and a 2-D affine Matrix (translate / scale / rotate / shear, composed, inverted, and applied to points and rectangles).
Package geometry is go-gfx's floating-point 2-D geometry substrate: a Point, an axis-aligned Rect, and a 2-D affine Matrix (translate / scale / rotate / shear, composed, inverted, and applied to points and rectangles).
Package raster is the shared pixel-buffer substrate of go-gfx: a densely packed 8-bit RGBA image the higher layers (resample, color, and the fleet's image-processing and rendering libraries) read and write.
Package raster is the shared pixel-buffer substrate of go-gfx: a densely packed 8-bit RGBA image the higher layers (resample, color, and the fleet's image-processing and rendering libraries) read and write.
Package resample resizes RGBA images with a choice of separable filters: nearest-neighbour, bilinear, box/area, bicubic (Catmull-Rom) and Lanczos (a=3).
Package resample resizes RGBA images with a choice of separable filters: nearest-neighbour, bilinear, box/area, bicubic (Catmull-Rom) and Lanczos (a=3).
Package vector is go-gfx's pure-Go 2-D vector rasterizer: it turns arbitrary outlines (move / line / quadratic / cubic / close) into per-pixel coverage, with an anti-aliased scanline accumulator and a round-join / round-cap stroker.
Package vector is go-gfx's pure-Go 2-D vector rasterizer: it turns arbitrary outlines (move / line / quadratic / cubic / close) into per-pixel coverage, with an anti-aliased scanline accumulator and a round-join / round-cap stroker.

Jump to

Keyboard shortcuts

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