Last active
December 7, 2021 08:24
-
-
Save duongdam/45a838aeb55af2cee72726c0167f3d1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
// use usePanter2D.js to drawing | |
interface Props { | |
canvasRef?: React.MutableRefObject<HTMLCanvasElement | undefined>; | |
width?: number; | |
} | |
export const Canvas: React.FC<Props> = ({ canvasRef, width }) => { | |
const widthHalf = width ? width / 2 : 0; | |
const cursor = `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="%23000000" opacity="0.3" height="${width}" viewBox="0 0 ${width} ${width}" width="${width}"><circle cx="${widthHalf}" cy="${widthHalf}" r="${widthHalf}" fill="%23000000" /></svg>') ${widthHalf} ${widthHalf}, auto`; | |
return ( | |
<section> | |
<canvas style={{ cursor }} ref={canvasRef as any} /> | |
</section> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment