1.0.0 • Published 5 years ago
react-fullscreen-canvas v1.0.0
react-fullscreen-canvas
a fullscreen HTML Canvas wrapper for React
Installation
npm:
npm install react-fullscreen-canvas --save
yarn:
yarn add react-fullscreen-canvas
Use
import React from 'react';
import Canvas from 'react-fullscreen-canvas';
const TestComponent = () => {
// Called on initial render and whenever canvas is resized
const setup = (context, size) => {
// ...
};
// Called once per frame (before draw)
const predraw = (context, size, deltaTime) => {
// ...
};
// Called once per frame
const draw = (context, size, deltaTime) => {
// ...
};
// Called once per frame (after draw)
const postdraw = (context, size, deltaTime) => {
// ...
};
// Return Canvas component with these optional props and any HTMLCanvasElement props
return <Canvas onSetup={setup} onDraw={draw} targetFrameRate={60} />;
};
1.0.0
5 years ago