AGG.rs

April 20, 2026 · View on GitHub

License: BSD-3-Clause Crates.io Tests Modules Demos

A pure Rust port of Anti-Grain Geometry (AGG) 2.6 — the legendary high-quality 2D software rendering library originally written in C++ by Maxim Shemanarev. Zero external dependencies. Pixel-perfect anti-aliased output. No GPU required.

Try the Interactive Demo — 64 demos running entirely in your browser via WebAssembly.

Crate listing: agg-rust on crates.io.

Part of the rust-apps suite — a collection of Rust graphics and geometry libraries by Lars Brubaker.

AGG.rs Interactive Demo — Lion rendering with anti-aliased vector graphics

Features

AGG is a software rendering engine that produces pixel images in memory from vectorial data. It is platform-independent and achieves exceptional rendering quality through:

  • Anti-Aliasing — subpixel-accurate scanline rasterization
  • Affine & Perspective Transforms — rotation, scaling, skewing, and full perspective warps
  • Gradient Fills — linear, radial, focal-point, and custom gradient functions with multi-stop color interpolation
  • Gouraud Shading — smooth per-vertex color interpolation across triangles and meshes
  • Image Filtering — 17 interpolation filters including bilinear, bicubic, sinc, Blackman, and more
  • 30+ Compositing Modes — full SVG 1.2 compatible Porter-Duff and blend operations
  • Stroke & Dash Generation — configurable line joins, caps, dashes, and markers
  • Alpha Masking — arbitrary clip regions through grayscale alpha masks
  • Stack Blur — fast approximate Gaussian blur with adjustable radius
  • Pattern Fills — tiled and resampled pattern rendering with perspective support
  • Built-in Fonts — 34 embedded bitmap fonts plus vector text via GSV text engine
  • Boolean Operations — scanline-level union, intersection, difference, and XOR

Architecture

AGG uses a five-stage rendering pipeline with interchangeable components:

Vertex Source → Coordinate Conversion → Scanline Rasterizer → Scanline Container → Renderer

Each stage is a trait in the Rust port, allowing components to be freely mixed and matched:

StagePurposeExamples
Vertex SourceGenerates path verticesPathStorage, Ellipse, RoundedRect, GsvText
Coordinate ConversionTransforms and processes pathsConvCurve, ConvStroke, ConvDash, ConvTransform
Scanline RasterizerConverts paths to scanlinesRasterizerScanlineAa, RasterizerCompoundAa
Scanline ContainerStores scanline coverage dataScanlineU8, ScanlineP8, ScanlineBin
RendererWrites pixels to the bufferRendererScanlineAaSolid, RendererBase, pixel formats

Interactive Demos

All 64 demos run in-browser via WebAssembly with no server-side processing. Categories include:

CategoryDemosHighlights
Anti-AliasingAA Demo, Rasterizers, Gamma, AA TestSubpixel rendering quality visualization
RenderingLion, Perspective, Circles, Alpha Masks, BlurComplex vector scenes with transforms
GradientsLinear/Radial, Gouraud, Focal Point, MeshMulti-stop color interpolation
Paths & StrokesStroke, Contour, Dash, Line PatternsJoin/cap styles, dash patterns
CurvesBezier, B-Spline, Text on CurveInteractive control point editing
Images & Filters17 Filter Types, Perspective, ResampleImage transform and filter quality
CompositingSVG Blend Modes, Flash RasterizerPorter-Duff and blend operations
PatternsPattern Fill, Perspective, ResampleTiled pattern rendering
TextGSV Vector Text, 34 Raster FontsBuilt-in font rendering

Browse all demos →

Quick Start

[dependencies]
agg-rust = "1.0"
use agg_rust::*;

// Create a rendering buffer
let mut buf = vec![0u8; width * height * 4];
let mut rbuf = RenderingBuffer::new(&mut buf, width, height, width * 4);

// Set up the pixel format and renderer
let mut pixfmt = PixfmtRgba32::new(&mut rbuf);
let mut ren_base = RendererBase::new(&mut pixfmt);
ren_base.clear(&Rgba8::new(255, 255, 255, 255));

// Create a path and rasterize it
let mut path = PathStorage::new();
path.move_to(10.0, 10.0);
path.line_to(100.0, 50.0);
path.line_to(50.0, 100.0);
path.close_polygon();

let mut ras = RasterizerScanlineAa::new();
let mut sl = ScanlineU8::new();
ras.add_path(&mut path);
render_scanlines_aa_solid(&mut ras, &mut sl, &mut ren_base, &Rgba8::new(200, 80, 80, 255));

Development

Prerequisites

  • Rust 1.70+ (rustup install stable)
  • wasm-pack (for WASM demos)
  • Bun (for demo dev server)

Building & Testing

cargo build
cargo test                    # 903 tests
cargo clippy -- -D warnings

Running the Demo Locally

cd demo
bun install
bun run build:wasm
bun run dev

Then open http://localhost:3000 in your browser.

Project Status

All 88 core library modules have been ported from the C++ original with 903 tests passing. All 64 applicable demos are fully implemented and running via WebAssembly.

MetricValue
Core modules ported88
Tests passing903
Interactive demos64
External dependencies0
GPU dependencies0

License

BSD-3-Clause — see LICENSE.

Based on the original Anti-Grain Geometry library by Maxim Shemanarev, dual-licensed under the Modified BSD License and the Anti-Grain Geometry Public License.

Note: The GPC (General Polygon Clipper) component from the original library is excluded from this port due to its non-commercial license restriction.

Acknowledgments

  • Maxim Shemanarev (1966–2013) — creator of Anti-Grain Geometry, a masterwork of C++ library design
  • ghaerr/agg-2.6 — the GitHub mirror of AGG 2.6 used as reference
  • Ported by Lars Brubaker, sponsored by MatterHackers