Grida Canvas is a safe, high-performance 2D real-time rendering engine for the Grida design tool. It provides a node- and property-based graphics API with support for modern design techniques.
- Rendering:
skia-safefor painting - Geometry & math:
math2for transforms, rects, and common operations
| Node | Status |
|---|---|
| Container (Frame) | ✅ |
| Group | ✅ |
| Rectangle | ✅ |
| Ellipse (incl. arc, ring, sector) | ✅ |
| Polygon, RegularPolygon, RegularStarPolygon | ✅ |
| Line | ✅ |
| Path (SVG path) | ✅ |
| Vector (vector network) | ✅ |
| BooleanOperation | ✅ |
| TextSpan | ✅ |
| Image | ✅ |
| InitialContainer, Error | ✅ |
- Fills: Solid, LinearGradient, RadialGradient, SweepGradient, Image (with fit and image filters)
- Strokes: Stroke width (uniform/variable), dash array, caps/joins, stroke alignment, rect-specific stroke widths, markers
- Effects: Layer blur, backdrop blur, drop/inner shadow, liquid glass, noise
- Blend modes on layers and paints
- Taffy-based layout: flex (direction, alignment, gap, padding), positioning (inset, width/height), transform
- Masks (layer and vector masks)
- Camera: 2D camera (pan, zoom, viewport)
- Resources: Font loading (
FontRepository), image loading (ImageRepository), embedded fonts (e.g. Geist, Geist Mono) - Export: PNG, JPEG, WEBP, BMP, PDF, SVG
- Hit testing:
HitTesterfor point-in-node and hit-test queries
| Module | Description |
|---|---|
io::io_grida_fbs |
Encode/decode .grida FlatBuffers binaries. Bindings are generated from format/grida.fbs via flatc --rust (see repo root and format/README.md). |
io::io_grida_file |
Unified loader that auto-detects raw FlatBuffers vs ZIP-wrapped .grida files. |
import::svg, import::html |
External-format importers (SVG, HTML) that produce a Grida SceneGraph or .grida bytes. |
formats::svg, formats::markdown |
Format-internal utilities (sanitize, optimize, parse, markdown→HTML) — no Grida types in or out. See src/formats/README.md. |
Raw FlatBuffers test fixtures live in fixtures/test-grida/ at the repo root. In-memory round-trip tests are in cargo test --package grida --test fbs_roundtrip. See the fixtures directory README for format and version details.
The canvas uses a dual-ID system:
- NodeId (
u64): Internal counter-based IDs for high-performance operations. Ephemeral and not serialized. - UserNodeId (
String): External user-provided IDs for public APIs. Stable and serialized in.gridafiles.
See AGENTS.md for details and migration notes.
# run tests
cargo test
# run fmt
cargo fmt
# run check
cargo check
cargo check --all-targets --all-features
# run clippy (no deps — skips re-checking skia etc.)
cargo clippy --no-deps --all-targets --all-features
# run build
cargo build
# run examples (many require window/GPU; headless_gpu requires native-gl-context)
cargo run --example <example-name>
cargo run --example headless_gpu --features native-gl-contextcargo doc --package grida --open --no-deps