// Device pixel ratio helpers. Clamped to 2 to keep canvases under iOS 15 GPU // process limits (research 01 §canvas). const MAX_DPR = 2; const MAX_BACKING_WIDTH = 2048; export function getDpr(): number { if (typeof window === 'undefined') return 1; const dpr = window.devicePixelRatio ?? 1; return Math.min(Math.max(dpr, 1), MAX_DPR); } export function backingWidth(cssWidth: number, dpr = getDpr()): number { return Math.min(Math.round(cssWidth * dpr), MAX_BACKING_WIDTH); } export function backingHeight(cssHeight: number, dpr = getDpr()): number { return Math.round(cssHeight * dpr); }