// Write model-space coordinates for the supplied node slots
ctx.setPositions(slots: number[], xy: number[] | Float32Array): voidWrite model-space coordinates for the supplied node slots. For each index i, xy[i * 2] and xy[i * 2 + 1] are the x and y values for slots[i]. Use this helper to keep rendering and compound bounds up to date.
| Name | Description |
|---|---|
slots: number[] | the node slots to move |
xy: number[] | Float32Array | the packed positions: |
Returns
voidExample
// Inside a custom layout, ctx is supplied by the library.cy.layout({ impl: { run(ctx) { const slots = Array.from(ctx.nodeSlots()); ctx.setPositions(slots, slots.flatMap((slot, i) => [i * 40, 0]));} } }).run();console.log(cy.getElementById('b').position('x')); // 40