Arrange nodes on a canvas
Lay out existing nodes with Fuser's layout instead of working out positions. Without layout it tidies them along their wiring, inputs to the left of what they feed; with layout it puts them in a row, column or grid in nodeIds order. To lay out a board of several blocks (a column of references, a grid of finals), pass blocks in one call instead of one call per block. Without an origin the block stays where the nodes are and slides clear of the nodes around it. canvas_edit already lays out the nodes it adds, so use this only when the user asks to rearrange, line up or tidy nodes, or after resizing nodes that now overlap. Arrange only the nodes the request is about; a whole-canvas re-layout (all) needs the user's explicit request and confirm. For wired nodes leave layout out: tidying keeps each wire short and gives fan-outs room. Rows, columns and grids are for unwired sets (references, finals); a row of nodes wired in sequence or to one shared node runs wires through each other. Keep work flowing left to right: a block sits left of the blocks it feeds (hero shots, then their crops, then videos); stack blocks top to bottom only when they don't feed each other. It changes positions only.
/v1/canvas_arrangecanvas_arrangeTry it
{
"canvasId": "3f2b8c1e-7a4d-4e9b-9c2a-5d6e7f8a9b0c",
"url": "https://media.fuser.studio/9c2a5d6e7f8a.png",
"revision": 1,
"arranged": 1,
"moved": 1,
"bounds": {
"x": 1,
"y": 1,
"width": 1,
"height": 1
},
"blockBounds": [
{
"x": 1,
"y": 1,
"width": 1,
"height": 1
}
],
"overlaps": [],
"warnings": []
}Example
curl -X POST https://api.fuser.studio/v1/canvas_arrange \
-H "x-api-key: $FUSER_API_KEY" \
-H "content-type: application/json" \
-d '{
"canvasId": "3f2b8c1e-7a4d-4e9b-9c2a-5d6e7f8a9b0c"
}'const result = await fuser.canvas.arrange({
canvasId: '3f2b8c1e-7a4d-4e9b-9c2a-5d6e7f8a9b0c',
});See the TypeScript SDK.
Input
canvasIdstringrequiredThe canvas id. Pass it to canvas_get, canvas_edit and run_start.
nodeIdsstring[]Nodes to arrange, all at the top level or all in the same group. With layout, this order is the placement order.
allbooleanTidy the whole canvas: lays each wired part out again in columns by its wiring, inputs to the left, keeping what is above what; a group moves with the part it is wired into, and lone unwired nodes and groups keep their place. Only when the user explicitly asked to reorganize, clean up or tidy the whole canvas in this conversation, never on your own initiative and never after adding nodes: it can nudge every node. Without confirm it moves nothing and says how much would move; tell the user, and pass confirm only once they agree. canvas_undo reverses it.
confirmbooleanWith all: apply the whole-canvas re-layout. Only after the user explicitly asked for it and agreed to what will move.
expectedRevisionintegerThe revision from your latest canvas_get or canvas_edit; the call is refused if the canvas changed since, and the refusal gives the current revision.
Output
canvasIdstringThe canvas id. Pass it to canvas_get, canvas_edit and run_start.
urlstringrevisionnumberThe canvas revision after this call. Pass it as expectedRevision on your next canvas_edit.
arrangednumbermovednumberwarningsstring[]Only when the layout couldn't be done cleanly and some or all nodes stayed where they were; says why.
Edit a canvas
Apply a graph diff to a canvas all at once: add nodes and edges, change inputs, disconnect edges, delete nodes. Every change lands or none does. Keep each edit to about 30 new nodes; build a bigger canvas one section per edit, so a mistake costs one small resend.
Undo recent edits
Reverses the latest edits made through this API (canvas_edit, canvas_arrange): nodes they added are removed, nodes they deleted come back (without their results), and moves, wiring, inputs and names return to how they were. Results are never regenerated. A node someone changed after the edit is left as it is and listed in skipped. Use it when the user says undo, revert or go back, or to fix your own mistake, instead of rebuilding by hand.