Git Product home page Git Product logo

fireworks-js's Introduction



fireworks-js

A simple fireworks library! | fireworks.js.org

GitHub Workflow Status npm npm npm bundle size CodeFactor Grade

Features | Demo | Installation | Usage | Options

Features

Demo

You can play with fireworks-js on fireworks.js.org or codesandbox.io

Edit fireworks-js

Installation

# with npm:
npm install fireworks-js

# or yarn:
yarn add fireworks-js

Usage

If you are using a module bundler like Webpack or Rollup, etc.., import fireworks-js into your project:

import { Fireworks } from 'fireworks-js'

const container = document.querySelector('.fireworks-container')
const fireworks = new Fireworks(container, { /* options */ })

fireworks.start()
fireworks.pause()
fireworks.clear()

// stop and clear fireworks
fireworks.stop()

// after initialization you can change the fireworks parameters
fireworks.setOptions({ delay: { min: 10, max: 15 }})

Using the CDN

<!-- jsdelivr  -->
<script src="https://cdn.jsdelivr.net/npm/fireworks-js@latest/dist/fireworks.js"></script>

<!-- unpkg -->
<script src="https://unpkg.com/fireworks-js@latest/dist/fireworks.js"></script>

Usage in React (with hook useFireworks)

import { Fireworks } from 'fireworks-js/dist/react'

export const App = () => {
  const options = {
    speed: 3
  }

  const style = {
    top: 0,
    left: 0,
    width: '100%',
    height: '100%',
    position: 'fixed',
    background: '#000'
  }

  return <Fireworks options={options} style={style} />
}

Server-Side Rendering (with-no-ssr)

// components/Fireworks.tsx
import { Fireworks } from 'fireworks-js/dist/react'

export default () => <Fireworks />

// pages/index.tsx
import dynamic from 'next/dynamic'

const FireworksWithNoSSR = dynamic(
  () => import('../components/Fireworks'),
  { ssr: false }
)

Options

NameTypeDefaultDescription
hueobject{ min: 0, max: 360 }-
rocketsPointnumber50-
opacitynumber0.5-
accelerationnumber1.05-
frictionnumber0.95-
gravitynumber1.5-
particlesnumber50-
tracenumber3-
explosionnumber5-
autoresizebooleantrue-
mouseobject{ click: false, move: false, max: 3 }-
boundariesobject{ visible: false, x: 50, y: 50, width: container.clientWidth, height: container.clientHeight }-
sound.enabledbooleanfalse-
sound.filesstring[][ 'explosion0.mp3', 'explosion1.mp3', 'explosion2.mp3' ]-
sound.volumeobject{ min: 1, max: 2 }-
delayobject{ min: 15, max: 30 }-
brightnessobject{ min: 50, max: 80, decay }-
brightness.decayobject{ min: 0.015, max: 0.03 }-
flickeringnumber50-
intensitynumber30-
traceSpeednumber10-
lineWidthobject{ explosion: { min: 0, max: 0 }, trace: { min: 0, max: 0 } }-
lineStyle'round' | 'square''round'-

License

MIT License ยฉ 2021 Vitalij Ryndin

fireworks-js's People

Contributors

crashmax-dev avatar dependabot[bot] avatar actions-user avatar cwbudde avatar dineshsonachalam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.