2.2.7 • Published 4 years ago

fireworks v2.2.7

Weekly downloads
202
License
MIT
Repository
github
Last release
4 years ago

Demo GIF of fireworks being rendered

import fx from 'fireworks'

fx({
  x: number // required
  y: number // required

  // optional
  count?: number
  colors?: string[]
  canvasWidth?: number
  canvasHeight?: number
  canvasTopOffset?: number
  canvasLeftOffset?: number
  bubbleSizeMinimum?: number
  bubbleSizeMaximum?: number
  bubbleSpeedMinimum?: number
  bubbleSpeedMaximum?: number
  particleTimeout?: number
  parentNode?: HTMLElement
})

Installation

Install with npm:

$ npm install fireworks --save

Or with yarn:

$ yarn add fireworks

Usage

Each time you call the fireworks() function, a canvas gets rendered with fireworks at position (x,y) like this:

const fireworks = require('fireworks')

fireworks({
  x: window.innerWidth / 2,
  y: window.innerHeight / 2,
  colors: ['#cc3333', '#4CAF50', '#81C784']
})

If you want render multiple, you can loop through randomly:

import fx from 'fireworks'

let range = n => [...new Array(n)]

range(6).map(() =>
  fx({
    x: Math.random(window.innerWidth / 2) + window.innerWidth / 4,
    y: Math.random(window.innerWidth / 2) + window.innerWidth / 4,
    colors: ['#cc3333', '#4CAF50', '#81C784']
  })
)

For React apps, you can optionally use the component:

// You need to install React/React-DOM
import { Fireworks } from 'fireworks/lib/react'

function App() {
  let fxProps = {
    count: 3,
    interval: 200,
    colors: ['#cc3333', '#4CAF50', '#81C784'],
    calc: (props, i) => ({
      ...props,
      x: (i + 1) * (window.innerWidth / 3) - (i + 1) * 100,
      y: 200 + Math.random() * 100 - 50 + (i === 2 ? -80 : 0)
    })
  }

  return (
    <div>
      <Fireworks {...fxProps} />
      <h1>Congrats!</h1>
    </div>
  )
}

NodeConf Fireworks

Looking for Eran Hammer's fireworks from NodeConf? Check out https://github.com/hueniverse/fireworks

2.2.7

4 years ago

2.2.6

5 years ago

2.2.5

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.1

8 years ago

1.1.0

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago

0.0.0

11 years ago