On this page
Anchored canvas resize that remaps every frame's pixel and role buffers into new dimensions using a nine-way anchor, clipping overflow and filling exposed area.
#server.src.pixelweaver.resize
#server.src.pixelweaver.resize
Anchored canvas resize for the authoritative server state.
Resizing remaps every frame's per-layer RGBA buffer and role plane into a new-sized buffer, placing the old content according to an anchor (mirroring the nine-way anchor grid of the client's resize dialog). Content that falls outside the new bounds is clipped; newly-exposed area is transparent (RGBA 0,0,0,0 / role sentinel 0xFF).
Note: the client's resize_canvas command currently only opens a dialog and does not remap pixel buffers when the canvas dimensions change (a documented client limitation in src/lib/ui/image-commands.ts). This module implements the anchored buffer remap that authoritative server-side resize requires, so an MCP resize actually produces correctly-sized buffers rather than leaving stale ones behind.
#_anchor_offset
def _anchor_offset(anchor: str, old: int, new: int, *, axis: str) -> intPlacement offset of the old extent within the new extent for one axis.
#apply_resize
def apply_resize(canvas: CanvasState, new_width: int, new_height: int, anchor: str='top-left') -> NoneResize canvas in place to (new_width, new_height) using anchor.
Remaps every frame's RGBA and role buffers, then updates canvas dimensions. Raises ValueError on non-positive dimensions or an unknown anchor -- a hard error, never a silent no-op.