Node Graph UI Components
Relevant source files
The following files were used as context for generating this wiki page:
The Node Graph UI in Graphite provides a visual, nondestructive environment for defining graphical data transformations. It serves as an interchangeable view of the document structure, equivalent to the Layers panel, allowing users to switch between tool-centric layer editing and artist-friendly visual scripting. The system is built using a hybrid architecture where the frontend handles reactive UI presentation using Svelte, while the backend manages the complex business logic, state, and message-based communication.
Sources: website/content/features.md, frontend/src/README.md
Architecture and Data Flow
The Node Graph UI follows a strict separation of concerns between the frontend (TypeScript/Svelte) and the backend (Rust/WebAssembly). The frontend acts as an entry point for user input (e.g., dragging nodes, connecting links) and quickly hands off work to the WebAssembly editor backend via a Wasm wrapper API.
Communication Flow
- Frontend to Backend: User interactions trigger calls to the
EditorWrapper, which communicates with the backend message system. - Backend to Frontend: The editor queues
FrontendMessageswhich are dispatched to the frontend via asubscriptionsRouter. - Reactive State: Stores provide reactive state to Svelte components by subscribing to these frontend messages.
The diagram shows the bidirectional communication loop between the user interface and the Rust-based engine.
Sources: frontend/src/README.md, frontend/src/messages.ts
Core UI Components
The Node Graph UI consists of several primary entities that represent the data flow of the document artwork.
Nodes and Layers
- Nodes: Entities with left-to-right input connectors. They represent specific operations or generators (e.g.,
Rectangle,Blur). - Layers: Larger entities with thumbnails that stack data from bottom-to-top. Layers can act as "groups" when fed by other layer stacks.
- Links: Visual wires that send data from the output of one node to the input of another.
- Output Node: The final destination for graphical data, which is then rendered to the document viewport.
Sources: website/content/learn/_outline_draft.md
Interface Controls
The graph provides specific controls for manipulating these entities:
| Control | Description |
|---|---|
| Make Hidden/Visible | Toggles the visibility state; hidden nodes are bypassed in the data flow. |
| Preview | Temporarily moves the graph output to the selected node, bypassing the main Output node. |
| Double-Click | Used on nodes with internal networks to view and edit subgraphs. |
Sources: website/content/learn/_outline_draft.md, website/content/blog/2024-07-31-graphite-progress-report-q2-2024.md
Node Interface and Metadata
Nodes are defined by metadata that dictates how they are rendered in the UI and what inputs they accept. This metadata is used by documentation tools and the frontend to construct the interface dynamically.
Node Parameters
Nodes include various fields that are exposed as interactive widgets in the UI:
- Primary Input: Usually the first input (index 0), represented as the main data stream.
- Exposed Parameters: Parameters that can be toggled to appear as connectors in the graph for procedural animation.
- Value Sources: Parameters can be sourced from defaults, the scope, or direct user input.
The relationship between node metadata and its parameters as used by the UI generator.
Sources: tools/node-docs/src/page_node.rs
Navigation and Interaction
Recent updates have migrated interaction logic to the backend to enable consistent navigation across the viewport and the node graph.
- Navigation: Supports panning, zooming, and scrollbars, behaving similarly to the main document viewport.
- Auto-panning: The graph automatically pans when nodes are dragged near the edges of the panel.
- Tidy Organization: Features like nondestructive boolean operations and subgraphs assist in keeping the graph organized as complexity grows.
Sources: website/content/blog/2024-07-31-graphite-progress-report-q2-2024.md, website/content/features.md
Summary
The Node Graph UI components are a critical part of Graphite's hybrid editing philosophy. By combining a tool-centric frontend with a message-driven Rust backend, the system provides a powerful yet accessible environment for procedural 2D content creation. The components are designed to be interchangeable with the Layers panel, ensuring that users can leverage the power of node-based generative design without sacrificing the familiarity of traditional image editing workflows.