use-freehand
v1.2.6
Published
> react hook to use [perfect-freehand](https://github.com/steveruizok/perfect-freehand) with ease
Downloads
8
Readme
use-freehand
react hook to use perfect-freehand with ease
Install
npm install --save use-freehand
Usage
const FreehandCanvas: FC = () => {
const canvasRef = useRef<HTMLCanvasElement>(null);
const { capture, getRawData, reset } = useFreehand(canvasRef);
return <canvas ref={canvasRef} width={600} height={400} />;
};
API
useFreehand: (canvasRef: RefObject<HTMLCanvasElement>, options?: StrokeOptions) => {
capture: () => Promise<Blob>;
getRawData: () => number[][][];
reset: () => void;
};
capture: () => Promise<Blob>
captures the image on canvasgetRawData: () => number[][][]
returns arrays of pointsreset: () => void
clears the canvas