Just experiment with canvas 2d contex and particles, powered by React. (Demo Link)
Project consists of two parts:
src
- contain main moduleexample
- create-react-app for demo
- Clone repository
git clone https://github.com/rostegg/react-fireflies.git
cd react-fireflies && npm install && npm start
- Now main project is ready for development.
- For demo, open new terminal and
cd example && npm install && npm start
- Open http://localhost:3000/
Before deploy change repository
in package.json
npm run-script build
npm run-script predeploy
npm run-script deploy
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import Fireflies from 'react-fireflies'
ReactDOM.render(<Fireflies />, document.getElementById('root'))
Name | Value | Default | Description |
---|---|---|---|
width | PropTypes.number | window.innerWidth | Canvas width |
height | PropTypes.number | window.innerHeight | Canvas height |
updateInterval | PropTypes.number | 15 | Interval for update canvas (in ms) |
settings | PropTypes.object | More | More |
displayParamsChanger | PropTypes.bool | true | Enable/disable panel for manipulate settings |
displayFpsStats | PropTypes.bool | true | Enable/disable panel for display FPS |
Settings allow to manipulate fireflies particles on canvas.
Name | Value | Default | Description |
---|---|---|---|
color | Hex string | "#FF9B00" | Fireflies color |
size | Number | 4.7 | Firefly size |
speed | Number | 0.1 | Firefly move speed |
blur | Number | 0 | Blur effect for canvas (affect FPS) |
count | Integer number | 300 | Fireflies count |
fadeSpeedRate | Boolean | 0.01 | Flashing intensity |
differentSize | Boolean | true | Different size for all fireflies |
isGradient | Boolean | true | Graditent effect to draw a firefly (affect FPS) |
randomFadeTime | Boolean | true | Each firefly flashing at random time |