0.3.2 • Published 2 years ago

@9am/fire-flame v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Demo

https://user-images.githubusercontent.com/1435457/181478598-803a9822-247f-44e2-8643-3de775900153.mov

Packages

PackageStatusDescriptionInstallationLive Demo
@9am/fire-flamenpm.ioVanilla JSnpm install @9am/fire-flameEdit fire-flame
@9am/fire-flame-elementnpm.ioWeb Componentnpm install @9am/fire-flame-elementEdit fire-flame-element
@9am/fire-flame-reactnpm.ioReact Componentnpm install @9am/fire-flame-reactEdit fire-flame-react

Usage

@9am/fire-flame

import { FireFlame } from '@9am/fire-flame';

const ff = new FireFlame(document.querySelector('#container'), { /* option */ });

@9am/fire-flame-element

import '@9am/fire-flame-element';

// HTML
<fire-flame option='/* JSON.stringify(option) */'></fire-flame>

@9am/fire-flame-react

import { FireFlame } from '@9am/fire-flame-react';

// JSX
<FireFlame option={/* option */}></FireFlame>

Documentation

Option

NameTypeDefaultDescription
painter'canvas' | 'svg''canvas'the renderer for fire flame
wnumber400width
hnumber400height
xnumber0position x
ynumber0position y
mousemovebooleantrueenable mousemove
fpsnumber60render fps
windVectornew Vector({ x: 0, y: -0.8 })the Vector force applied to particles
frictionnumber0.98the friction applied to particles
particleNumnumber15the number of particle to draw the flame
particleDistancenumber10the distance between particles
particleFPSnumber10particle spawn fps
sizeCurveFnfunction() => x > 0.7 ? Math.sqrt(1 - x) 50 : Math.pow(x - 1, 2) -30 + 30define the size of the flame
innerColorstring'blue'flame color inner
outerColorstring'blueviolet'flame color outer

API

.start()

Start fire flame.

.stop()

Stop fire flame.

.setOption(option)

Update fire flame options.

.destroy()

Destroy fire flame.

License

MIT