@mocanvas/editor · function
declare function packShapes(editor: Editor, ids: readonly ShapeId[], gap?: number): voidPack shapes into a tight block, in place.
Shapes are laid out left to right in rows inside a square-ish area centred on
where they already are, keeping their reading order, with gap between them.
Sizes are never changed — packing is about removing whitespace, and a layout
that also resized things would be a different operation with a different undo
expectation.
SEMANTICS-ASSUMED: rows, ordered by the shapes' existing reading order, in a block whose target width is the square root of the total area. Row packing is the only layout that is stable — nudging one shape does not reshuffle the rest — which is what makes repeated packing idempotent.
mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.