@infinite-canvas-tutorial/webcomponents
Version:
WebComponents UI implementation
45 lines (44 loc) • 1.62 kB
TypeScript
/**
* Borrow from https://github.com/excalidraw/excalidraw/blob/d87620b23907cef9a119c758124569b5f44991a4/packages/excalidraw/animated-trail.ts
*/
import { LaserPointer, LaserPointerOptions } from '@excalidraw/laser-pointer';
import { API } from '@infinite-canvas-tutorial/ecs';
import { AnimationFrameHandler } from './animation-frame-handler';
export interface Trail {
start(container: SVGSVGElement): void;
stop(): void;
startPath(x: number, y: number): void;
addPointToPath(x: number, y: number): void;
endPath(): void;
}
export interface AnimatedTrailOptions {
fill: (trail: AnimatedTrail) => string;
stroke?: (trail: AnimatedTrail) => string;
fillOpacity?: (trail: AnimatedTrail) => number;
animateTrail?: boolean;
strokeDasharray?: string;
strokeDashoffset?: string;
}
export declare class AnimatedTrail implements Trail {
private animationFrameHandler;
protected api: API;
private options;
private currentTrail?;
private pastTrails;
private container?;
private trailElement;
private trailAnimation?;
constructor(animationFrameHandler: AnimationFrameHandler, api: API, options: Partial<LaserPointerOptions> & Partial<AnimatedTrailOptions>);
get hasCurrentTrail(): boolean;
hasLastPoint(x: number, y: number): boolean;
start(container?: SVGSVGElement): void;
stop(): void;
startPath(x: number, y: number): void;
addPointToPath(x: number, y: number): void;
endPath(): void;
getCurrentTrail(): LaserPointer;
clearTrails(): void;
private update;
private onFrame;
private drawTrail;
}