import { utils } from "pixi.js"; import { DBase } from "./d-base"; import { DOnOptions } from "./d-on-options"; import { DView } from "./d-view"; import { EShapeContainer } from "./shape/e-shape-container"; export interface DDiagramSnapshotParent { canvas: CANVAS | null; view: DView; } export interface DDiagramSnapshotEvents { /** * Triggered before taking a snapshot. * * @param canvas a canvas * @param emitter an emitter */ taking(canvas: CANVAS, emitter: EMITTER): void; /** * Triggered when a snapshot is taken successfully or when failed to take. * * @param canvas a canvas * @param reason Null if succeeded. Otherwise, a string representing a reason why failed. * @param emitter an emitter */ took(canvas: CANVAS, reason: string | null, emitter: EMITTER): void; } export interface DDiagramSnapshotCanvasSnap { container: EShapeContainer; } export interface DDiagramSnapshotCanvas extends DBase { snap?: DDiagramSnapshotCanvasSnap | null; } export interface DDiagramSnapshotOnOptions extends Partial>, DOnOptions { } /** * Options to eliminate the snap grid, the snap targets and the canvas background from a snapshot. */ export interface DDiagramSnapshotCleanupOptions { snap?: boolean; background?: boolean; reflow?: boolean; } export interface DDiagramSnapshotCreateAsUrlOptions { size?: number | null; cleanup?: boolean | DDiagramSnapshotCleanupOptions; } export interface DDiagramSnapshotCreateAsFileOptions { size?: number | null; filename: string; cleanup?: boolean | DDiagramSnapshotCleanupOptions; } export interface DDiagramSnapshotCreateOptions { size?: number | null; cleanup?: boolean | DDiagramSnapshotCleanupOptions; extractor: (canvas: CANVAS) => DATA; } export interface DDiagramSnapshotOptions { on?: DDiagramSnapshotOnOptions; } export declare class DDiagramSnapshot extends utils.EventEmitter { protected _parent: DDiagramSnapshotParent; constructor(parent: DDiagramSnapshotParent, options?: DDiagramSnapshotOptions); /** * Creates a snapshot. * * @param size a maximum image size * @returns an URL of a created image or undefined */ createAsUrl(size?: number | null): string | undefined; /** * Creates a snapshot. * * @param options options * @returns an URL of a created image or undefined */ createAsUrl(options: DDiagramSnapshotCreateAsUrlOptions): string | undefined; /** * Creates and downloads a snapshot. * * @param filename a filename */ createAsFile(filename: string): void; /** * Creates and downloads a snapshot. * * @param size a maximum image size * @param filename a filename */ createAsFile(size: number | null, filename: string): void; /** * Creates and downloads a snapshot. * * @param options options */ createAsFile(options: DDiagramSnapshotCreateAsFileOptions): void; protected toScale(size: number | null | undefined, canvas: CANVAS): number; protected toCleanupSnap(options?: DDiagramSnapshotCreateOptions): boolean; protected toCleanupBackground(options?: DDiagramSnapshotCreateOptions): boolean; protected toCleanupReflow(options?: DDiagramSnapshotCreateOptions): boolean; create(options: DDiagramSnapshotCreateOptions): DATA | undefined; }