@moefy-canvas/theme-sparkler
TypeScript icon, indicating that this package has built-in type declarations

0.5.2 • Public • Published

@moefy-canvas/theme-sparkler

type npm downloads downloads GitHub license

🎇 就是现在鼠标周围的粒子效果啦~

Install

pnpm add @moefy-canvas/theme-sparkler

Usage

<canvas id="moefy-canvas"></canvas>
import {
   Sparkler,
   SparklerMode,
   type SparklerConfig,
   type CanvasOptions,
   MAX_Z_INDEX,
} from '@moefy-canvas/theme-sparkler'

const themeConfig: SparklerConfig = {
   mode: SparklerMode.TRAIL,
}

const canvasOptions: CanvasOptions = {
   opacity: 1,
   zIndex: MAX_Z_INDEX,
}

const el = document.getElementById('moefy-canvas')
const sparkler = new Sparkler(themeConfig, canvasOptions)
sparkler.mount(el as HTMLCanvasElement)

ThemeConfig

export enum SparklerMode {
   FOLLOW = 'follow',
   TRAIL = 'trail',
}

export interface SparklerConfig extends ThemeConfig {
   mode?: SparklerMode
   numParticles?: number
   sparkleFactor?: number
   particleDurationRange?: [number, number]
   particleDistanceRange?: [number, number]
   particleSizeRange?: [number, number]
}

Package Sidebar

Install

npm i @moefy-canvas/theme-sparkler

Weekly Downloads

0

Version

0.5.2

License

MIT

Unpacked Size

13.2 kB

Total Files

10

Last publish

Collaborators

  • sigure_mo