"""Optional viewport notifications, independent of animation ownership."""fromtypingimportLiteral,Protocol,runtime_checkableResizePolicy=Literal["raise","resize"]def_size(size:tuple[int,int])->None:if(notisinstance(size,tuple)orlen(size)!=2orany(type(n)isnotintforninsize)):raiseTypeError("size must be a (width, height) tuple of integers")ifany(n<1forninsize):raiseValueError("viewport dimensions must be positive")
[docs]@runtime_checkableclassResizable(Protocol):"""Optional capability for animations receiving a new parent viewport. Dimensions are positive (width, height) in cells. A notification must not advance simulation, consume input, or restart/close existing children. Owners call it between frames, before drawing at the new size. Animations without this method must already draw into arbitrary buffer dimensions. """
[docs]defresize(self,size:tuple[int,int])->None:"""Reflow the view while retaining live animation and solver state."""...