inferno-canvas-component
v0.1.4
Published
Inferno Canvas Component
Downloads
9
Maintainers
Readme
inferno-canvas-component
Install
npm install --save inferno-canvas-component
Usage
import Inferno from 'inferno'
import Component from 'inferno-component'
import Canvas from 'inferno-canvas-component'
function drawCanvas({ctx, time}) {
const {width, height} = ctx.canvas
ctx.save()
ctx.clearRect(0, 0, width, height)
ctx.fillStyle = 'black'
ctx.translate(width / 2, height / 2)
ctx.rotate(((time / 10) % 360) * Math.PI / 180)
ctx.fillRect(-1 * width / 4, -1 * height / 4, width / 2, height / 2)
ctx.restore()
}
class App extends Component {
render() {
return <Canvas draw={drawCanvas} width={400} height={400} realtime/>
}
}
Inferno.render(<App/>, document.body)
Build
git clone https://github.com/nhz-io/inferno-canvas-component.git
cd inferno-canvas-component
npm install
npm start
...
check http://localhost:9000
...
npm run dist