Skip to main content

Essentials

Learn the basics of creating scenes with VizCraft.

The Builder API

VizCraft uses a fluent builder pattern to construct your scene. The entry point is the `viz()` function.

import { viz } from 'vizcraft';

const builder = viz().view(800, 600); // Set viewBox
builder.node('a').at(100, 100).circle(24).done(); // Add a node
const scene = builder.build(); // Finalize scene

View & Grid

You can define the canvas size with `.view(w, h)` and optionally set up a grid for easy positioning.

Nodes

Nodes are the primary entities in your graph. You can create them with `.node(id)`.

Shapes

VizCraft supports three built-in shapes:

  • `.circle(r)`
  • `.rect(w, h, [rx])`
  • `.diamond(w, h)`

Positioning

  • `.at(x, y)`: Absolute positioning.
  • `.cell(col, row, [align])` Grid-based positioning (requires `.grid()`).

Edges

Edges connect two nodes using `.edge(fromId, toId)`. By default, edges stop at the node boundary. Use `.connect('center')` to draw center-to-center.

Animations

For a full breakdown (registry/CSS animations, data-only timelines, playback controls, and live examples), see the dedicated guide: