0.1.5 • Published 8 years ago

react-canvas-component v0.1.5

Weekly downloads
9
License
MIT
Repository
github
Last release
8 years ago

react-canvas-component

Build Status NPM bitHound Code

Install

npm install --save react-canvas-component

Usage

import React from 'react'
import ReactDOM from 'react-dom'
import Canvas from 'react-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 React.Component {
    render() {
        return <Canvas draw={drawCanvas} width={400} height={400} realtime/>
    }
}

ReactDOM.render(<App/>, document.body)

Build

git clone https://github.com/nhz-io/react-canvas-component.git
cd react-canvas-component
npm install
npm start
...
check http://localhost:9000
...
npm run dist

LICENSE

MIT

VERSION

0.1.5

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago