weasel API - v0.8.0
    Preparing search index...

    Function useCanvasSize

    • Track a container's content-rect size via ResizeObserver, and density via the ambient DeviceProfile.

      This hook is the screen path's designated ambient-density source — rendering code should take density as a parameter (cf. renderSceneToPixels, renderSceneToCanvas's dpr) rather than reading window.devicePixelRatio inline.

      Density deliberately does NOT come from a window.devicePixelRatio read inside the resize callback: that only refreshes when the element resizes, so dragging a window to a different-density display without resizing it left the snapshot stale. The profile watches a re-armed resolution media query instead.

      Parameters

      • containerRef: RefObject<HTMLDivElement | null>

      Returns CanvasSizeSnapshot