canvist_canvas 0.2.2

Headless interaction core for the canvist canvas: camera, spatial index, hit testing, selection, transform handles, snapping, and tools
Documentation

canvist_canvas

The headless interaction core of canvist's design canvas: everything between input and pixels, with no UI. Build your own Figma on top of it.

Most apps add it through canvist, the crate to install, as canvist::canvas behind the canvas feature: cargo add canvist --features canvas.

  • Camera: pan, zoom about a point, pinch, momentum that doesn't depend on frame rate, and zoom-to-fit.
  • Scene index: world transforms, auto-layout, boolean outlines, and an R-tree, updated only where a commit touched.
  • Hit testing: exact tests on fills, strokes, and curves, clipped by frames, plus marquee selection.
  • Transform handles: resize with aspect lock or from the centre, flip, rotate with snapping, and skew.
  • Snapping: smart guides from nearby edges and centres, grid snapping, and ruler ticks.
  • Tools as typed extensions: select, hand, rectangle, ellipse, polygon, frame, pen, and text, with inspectors as data any host or agent can read.
  • Overlay as data: selection outlines, handles, guides, and pen previews. Draw them yourself or hand them to canvist_paint.

At 100,000 nodes, a hit test takes about 0.3 µs and a drag step about 1.3 µs. Run cargo bench -p canvist_canvas to reproduce.