Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

nhz-io/inferno-canvas-component

Repository files navigation

inferno-canvas-component

Build Status NPM bitHound Code

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

LICENSE

0.1.4