transfer-out: transfer out
This commit is contained in:
parent
ec84f64e63
commit
29ed921c67
1056 changed files with 154507 additions and 0 deletions
14
packages/ui/src/lib/hooks/useHighDpiCanvas.ts
Normal file
14
packages/ui/src/lib/hooks/useHighDpiCanvas.ts
Normal 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])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue