UNPKG

1.85 kBTypeScriptView Raw
1import type { Container } from "./Container";
2import type { Particle } from "./Particle";
3import type { IContainerPlugin, ICoordinates, IDelta, IDimension, IParticle, IRgb } from "./Interfaces";
4/**
5 * Canvas manager
6 * @category Core
7 */
8export declare class Canvas {
9 private readonly container;
10 /**
11 * The particles canvas
12 */
13 element?: HTMLCanvasElement;
14 /**
15 * The particles canvas dimension
16 */
17 readonly size: IDimension;
18 resizeFactor?: IDimension;
19 /**
20 * The particles canvas context
21 */
22 private context;
23 private generatedCanvas;
24 private coverColor?;
25 private trailFillColor?;
26 private originalStyle?;
27 /**
28 * Constructor of canvas manager
29 * @param container the parent container
30 */
31 constructor(container: Container);
32 /**
33 * Initializes the canvas element
34 */
35 init(): void;
36 loadCanvas(canvas: HTMLCanvasElement, generatedCanvas?: boolean): void;
37 destroy(): void;
38 /**
39 * Paints the canvas background
40 */
41 paint(): void;
42 /**
43 * Clears the canvas content
44 */
45 clear(): void;
46 windowResize(): void;
47 /**
48 * Calculates the size of the canvas
49 */
50 resize(): void;
51 drawConnectLine(p1: IParticle, p2: IParticle): void;
52 drawGrabLine(particle: IParticle, lineColor: IRgb, opacity: number, mousePos: ICoordinates): void;
53 drawParticle(particle: Particle, delta: IDelta): void;
54 drawPlugin(plugin: IContainerPlugin, delta: IDelta): void;
55 drawParticlePlugin(plugin: IContainerPlugin, particle: Particle, delta: IDelta): void;
56 initBackground(): void;
57 draw<T>(cb: (context: CanvasRenderingContext2D) => T): T | undefined;
58 private initCover;
59 private initTrail;
60 private getPluginParticleColors;
61 private initStyle;
62 private paintBase;
63 private lineStyle;
64}