transfer-out: transfer out

This commit is contained in:
alex 2023-04-25 12:01:25 +01:00
parent ec84f64e63
commit 29ed921c67
1056 changed files with 154507 additions and 0 deletions

View file

@ -0,0 +1,14 @@
import { useLayoutEffect } from 'react'
/** @public */
export function useHighDpiCanvas(ref: React.RefObject<HTMLCanvasElement>, dpr: number) {
// Match the resolution of the client
useLayoutEffect(() => {
const canvas = ref.current
if (!canvas) return
const rect = canvas.getBoundingClientRect()
canvas.width = rect.width * dpr
canvas.height = rect.height * dpr
}, [ref, dpr])
}