1.0.7 • Published 9 years ago

react-pump v1.0.7

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

react-pump

Canvas based flash like animation library.

Install

npm install react-pump

Animation lyfecycle

...

Usage

At first, import module

  • Pump: this is Main react component.
  • View: this is animation sprite base class.
import { Pump, View } from 'react-pump'

class RootView extends View {
  constructor() {
    super()
    // you can define any properties for the class
    this.points = []
    this.on('added',() => {
      for(let i=0;i<500;i++) {
        this.points.push({
          x:Math.random()*this.width,
          y:Math.random()*this.height
        })
      }
    })
  }
  // function will be called in animation loop.
  draw() {
    // Sprite has { context,canvas,width,height } getters.
    let { points } = this

    // save style
    this.pushStyle()

    this.context.strokeStyle = '#000'
    this.context.lineWidth = 4
    this.context.beginPath()
    points.forEach(p=>{
      this.context.lineTo(
        (Math.random()-0.5)*10+p.x,
        (Math.random()-0.5)*10+p.y
      )
    })
    this.context.stroke()

    // restore style
    this.popStyle()
  }
}

react render function.

render() {
  return (
    <Pump root={RootSprite} framerate={30} width={640} height={480}/>
  )
}

Demo

https://yusukeshibata.github.io/react-pump/

License

MIT

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.5.8

9 years ago

0.5.7

9 years ago

0.5.6

9 years ago

0.5.5

9 years ago

0.5.4

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.9

9 years ago

0.4.8

9 years ago

0.4.7

9 years ago

0.4.6

9 years ago

0.4.5

9 years ago

0.4.4

9 years ago

0.4.3

9 years ago

0.4.2

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.9

9 years ago

0.3.8

9 years ago

0.3.7

9 years ago

0.3.6

9 years ago

0.3.5

9 years ago

0.3.4

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.9

9 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.1.9

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.9

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago