Skip to content
This is the alpha v4 version website. Looking for the v3 documentation?

createNodeProgram

createNodeProgram<N, E, G>(options): NodeProgramType<N, E, G>

Defined in: packages/sigma/src/rendering/nodes/factory.ts:68

Creates a node program from SDF shape(s) and fragment layers. The resulting program renders nodes as quads with the specified shape(s) and layers. It also includes a static LabelProgram property for rendering shape-aware labels.

Supports two modes:

  • Single shape: Use shape for a program that renders one shape type
  • Multi-shape: Use shapes for a program that can render different shapes per node

Type Parameters

N

N extends Attributes = Attributes

E

E extends Attributes = Attributes

G

G extends Attributes = Attributes

Parameters

options

NodeProgramOptions

Configuration for the node program

Returns

NodeProgramType<N, E, G>

A NodeProgram class that can be used with Sigma

Examples

// Single shape (backward compatible)
import { createNodeProgram, sdfCircle, layerFill } from "sigma/rendering";
const CircleProgram = createNodeProgram({
shape: sdfCircle(),
layers: [layerFill()],
});
// Multi-shape program
const MultiShapeProgram = createNodeProgram({
shapes: [sdfCircle(), sdfSquare(), sdfTriangle(), sdfDiamond()],
layers: [layerFill(), layerBorder({ ... })],
});
// Nodes select their shape via the 'shape' attribute
graph.setNodeAttribute(node, 'shape', 'square');