jparticles
Version:
A lightweight, efficient and easy-to-use Canvas library for building some cool particle effects.
42 lines (41 loc) • 1.27 kB
TypeScript
/// <reference path="types/global.d.ts" />
import Shape from "./common/shape";
import type { IElement, Options } from "./types/snow";
export default class Snow extends Shape<Options> {
static defaultConfig: Options;
protected elements: IElement[];
private startTime;
private isFinished;
constructor(selector: string | HTMLElement, options?: Partial<Options>);
/**
* 初始化数据和运行程序
*/
protected init(): void;
/**
* 创建单个雪花,包含大小、位置、速度等信息
*/
private createSnowflake;
/**
* 随机创建雪花
*/
private createSnowflakes;
/**
* 绘图
* 设计一种模式(解耦逻辑混杂),当触发 resize 事件调用 draw 方法时:
* 如果是暂停 -> 调用 elements 的重新绘制 drawShape()
* 如果是运动中 -> 正常逻辑,内部不考虑暂停逻辑
*/
protected draw(): void;
/**
* 更新元素自旋数据
*/
private updateElementRotate;
/**
* 方法:当存在持续时间时,再次下雪
*/
fallAgain(): void;
/**
* 事件:当存在持续时间时,雪花全部降落后触发的事件
*/
onFinished(...args: Array<() => void>): this;
}