1.0.7 • Published 7 years ago

react-pump v1.0.7

Weekly downloads
7
License
MIT
Repository
github
Last release
7 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

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.5.8

7 years ago

0.5.7

7 years ago

0.5.6

7 years ago

0.5.5

8 years ago

0.5.4

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.9

8 years ago

0.4.8

8 years ago

0.4.7

8 years ago

0.4.6

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.9

8 years ago

0.3.8

8 years ago

0.3.7

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.1.9

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

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

8 years ago

0.1.0

8 years ago

0.0.9

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago