import * as _drincs_pixi_vn_pixi_js from '@drincs/pixi-vn/pixi.js'; import _drincs_pixi_vn_pixi_js__default, { Container as Container$1, ContainerChild as ContainerChild$1, Ticker as Ticker$1, UPDATE_PRIORITY as UPDATE_PRIORITY$1, Application, Rectangle as Rectangle$1, ApplicationOptions, PointData, ContainerOptions as ContainerOptions$1, SpriteOptions as SpriteOptions$1, CanvasTextOptions, Texture as Texture$1, TextureSourceLike, ContainerEvents, EventEmitter, ObservablePoint, TextureSource, TextOptions as TextOptions$1 } from '@drincs/pixi-vn/pixi.js'; export { TextureSourceLike, Ticker as TickerValue } from '@drincs/pixi-vn/pixi.js'; import { ObjectTarget, AnimationOptions as AnimationOptions$1, At, SequenceOptions as SequenceOptions$1 } from 'motion'; export { AnimationOptions as MotionAnimationOptions } from 'motion'; import { Devtools } from '@pixi/devtools'; import { OnErrorHandler } from '@drincs/pixi-vn/core'; interface MotionComponentExtension { pivot?: number; pivotX?: number; pivotY?: number; scale?: number; scaleX?: number; scaleY?: number; } type AnimationOptionsCommon = Omit; type AnimationOptions = AnimationOptionsCommon & Omit; type KeyframesType = ObjectTarget & MotionComponentExtension; type SequenceOptions = SequenceOptions$1 & Omit; type ObjectSegment> = [ ObjectTarget & MotionComponentExtension ]; type ObjectSegmentWithTransition> = [ ObjectTarget & MotionComponentExtension, AnimationOptions & At ]; type Layer = Container$1; interface TickerArgs { } type TickerValue = Ticker$1; /** * A class is used to create a ticker element to add into a Pixi Application. * You can use {@link canvas.addTicker()} to add this element into the application. * This class should be extended and the fn method should be overridden. * You must use the {@link tickerDecorator} to register the ticker in the game. * In Ren'Py is a transform. * @template TArgs The type of the arguments that you want to pass to the ticker. * @example * ```typescript * \@tickerDecorator() // this is equivalent to tickerDecorator("RotateTicker") * export class RotateTicker extends TickerBase<{ speed?: number }> { * override fn( * t: TickerValue, // the ticker that is calling this method * args: { // the arguments that you passed when you added the ticker * speed?: number, * }, * aliases: string[], // the aliases of the canvas elements that are connected to this ticker * tickerId: string, // the id of the ticker. You can use this to get the ticker from the canvas.currentTickers * ): void { * let speed = args.speed === undefined ? 0.1 : args.speed * aliases.forEach((alias) => { * let element = canvas.find(alias) * if (element && element instanceof Container) { * if (clockwise) * element.rotation += speed * t.deltaTime * else * element.rotation -= speed * t.deltaTime * } * }) * } * } * ``` */ declare abstract class TickerBase implements Ticker { /** * @param args The arguments that you want to pass to the ticker. * @param options The options of the ticker. */ constructor(args: TArgs, options?: { /** * The duration of the ticker in seconds. If is undefined, the step will end only when the animation is finished (if the animation doesn't have a goal to reach then it won't finish). @default undefined */ duration?: number; /** * The priority of the ticker. @default UPDATE_PRIORITY.NORMAL */ priority?: UPDATE_PRIORITY$1; /** * The id of the ticker. This param is used by the system when will ber restoring the tickers from a save. If not provided, a random id will be generated. @default undefined */ id?: string; /** * The aliases of the canvas elements that are connected to this ticker. This is used by the system to know which canvas elements are connected to this ticker, and to pass them to the fn method. @default [] */ canvasElementAliases?: string[]; }); readonly alias: string; readonly id: string; args: TArgs; duration?: number; priority?: UPDATE_PRIORITY$1; protected ticker: _drincs_pixi_vn_pixi_js.Ticker; canvasElementAliases: string[]; private generateTickerId; /** * The method that will be called every frame. * This method should be overridden and you can use {@link canvas.add()} to get the canvas element of the canvas, and edit them. * @param _ticker The ticker that is calling this method * @param _args The arguments that you passed when you added the ticker * @param _alias The alias of the canvas elements that are connected to this ticker * @param _tickerId The id of the ticker. You can use this to get the ticker from the {@link canvas.currentTickers} */ abstract fn(_ticker: TickerValue, _args: TArgs, _alias: string | string[], _tickerId: string): void; protected fnValue?: () => void; complete(_options?: { ignoreTickerSteps?: boolean; }): void; stop(): void; start(): void; pause(): void; play(): void; get paused(): boolean; } interface Ticker { /** * Arguments to pass to the ticker */ args: TArgs; /** * Duration in seconds to run the ticker */ duration?: number; /** * Priority of the ticker */ priority?: UPDATE_PRIORITY$1; /** * Get the alias of the ticker class. This variable is used in the system to get the ticker class by id, {@link RegisteredTickers.getInstance} */ readonly alias: string; /** * The id of the ticker. Must be unique for each ticker instance. */ readonly id: string; /** * The aliases of the canvas elements that are connected to this ticker */ canvasElementAliases: string[]; /** * Completes the animation and applies the final state. */ complete: (options?: { ignoreTickerSteps?: boolean; }) => Promise | void; /** * Stops the animation at its current state, and prevents it from resuming when the animation is played again. */ stop: () => void; /** * Starts the ticker. This will start the ticker and begin the animation. */ start: () => void; /** * Pauses the animation. */ pause: () => void; /** * Plays the animation. */ play: () => void; /** * Checks if the ticker is paused. * @returns true if the ticker is paused, false otherwise. */ readonly paused: boolean; } /** * Is a decorator that register a ticker in the game. * Is a required decorator for use the ticker in the game. * Thanks to this decoration the game has the possibility of updating the tickers to the latest modification and saving the game. * @param name is th identifier of the label, by default is the name of the class * @returns */ declare function tickerDecorator(name?: string): (target: { new (args: any, options?: { duration?: number; priority?: UPDATE_PRIORITY$1; id?: string; canvasElementAliases?: string[]; }): Ticker; }) => void; declare namespace RegisteredTickers { /** * Register a ticker in the game. * @param target The class of the ticker. * @param name Name of the ticker, by default it will use the class name. If the name is already registered, it will show a warning */ function add(target: { new (args: any, options?: { duration?: number; priority?: UPDATE_PRIORITY$1; id?: string; canvasElementAliases?: string[]; }): Ticker; }, name?: string): void; /** * Get a ticker by the id. * @param canvasId The id of the ticker. * @returns The ticker type. */ function get>(tickerId: string): T | undefined; /** * Get a ticker instance by the id. * @param tickerId The id of the ticker. * @param args The arguments that you want to pass to the ticker. * @param duration The duration of the ticker. If is undefined, the ticker will be called every frame. * @param priority The priority of the ticker. If is undefined, the priority will be UPDATE_PRIORITY.NORMAL. * @returns The instance of the ticker */ function getInstance(tickerId: string, args: TArgs, options?: { duration?: number; priority?: UPDATE_PRIORITY$1; id?: string; canvasElementAliases?: string[]; }): Ticker | undefined; /** * Get a list of all tickers registered. * @returns An array of tickers. */ function values(): { new (args: any, options?: { duration?: number; priority?: UPDATE_PRIORITY$1; id?: string; canvasElementAliases?: string[]; }): Ticker; }[]; /** * Check if a ticker is registered. * @param id The id of the ticker. * @returns True if the ticker is registered, false otherwise. */ function has(id: string): boolean; /** * Get a list of all ticker ids registered. * @returns An array of label ids. */ function keys(): string[]; } /** * TickerHistory is a class that contains the name of a class and the arguments that were used to create it. */ interface TickerInfo { /** * If this ticker was created by steps */ createdByTicketSteps?: { canvasElementAlias: string; id: string; }; ticker: Ticker; } interface TickerHistory { id: string; args: TArgs; /** * The aliases of the canvas elements that are connected to this ticker */ canvasElementAliases: string[]; priority?: UPDATE_PRIORITY$1; duration?: number; paused?: boolean; } type TickerProgrationType = TickerProgrationLinear | TickerProgrationExponential; interface TickerProgrationLinear { /** * The amount of the speed to increase every frame. */ amt: number; /** * The limit of the effect */ limit?: number; type: "linear"; } interface TickerProgrationExponential { /** * The percentage of the speed to increase every frame. if the percentage is 0.1, the speed will increase by 10% every frame. */ percentage: number; /** * The limit of the effect */ limit?: number; type: "exponential"; } type PauseType = { /** * The type of the value */ type: "pause"; /** * Duration in seconds */ duration: number; }; type RepeatType = "repeat"; interface TickersStep { /** * Ticker class name */ ticker: string; /** * Duration in seconds. If is undefined, the step will end only when the animation is finished. */ duration?: number; /** * Arguments to pass to the ticker */ args: TArgs; /** * Priority of the ticker */ priority?: UPDATE_PRIORITY$1; } /** * The steps of the tickers */ interface TickersSequence { /** * The step number */ currentStepNumber: number; /** * The steps of the tickers */ steps: (TickersStep | RepeatType | PauseType)[]; } interface TickerTimeoutHistory { aliases: string[]; ticker: string; canBeDeletedBeforeEnd: boolean; } type CommonTickerProps = { /** * The alias to remove after the effect is done * @default [] */ aliasToRemoveAfter?: string[] | string; /** * If true, the effect only starts if the canvas element have a texture * @default false */ startOnlyIfHaveTexture?: boolean; /** * The alias to resume after the effect is done * @default [] */ tickerAliasToResume?: string[] | string; /** * The id of the ticker to resume after the effect is done * @default [] */ tickerIdToResume?: string[] | string; /** * @deprecated Use {@link completeOnContinue} instead. */ forceCompleteBeforeNext?: boolean; /** * When true, calling {@link narration.continue()} forces the current content to complete before advancing to the next narrative step. * @default false */ completeOnContinue?: boolean; }; /** * This class is used to create a canvas element to add into a Pixi Application. * You can use {@link canvas.add()} to add this element into the application. * This class should be implemented and the memory method should be overridden. * You must use the {@link canvasComponentDecorator} to register the canvas in the game. * In Ren'Py is a displayable. * @example * ```typescript * const CANVAS_EXAMPLE_ID = "CanvasExample"; * * \@canvasComponentDecorator({ * name: CANVAS_EXAMPLE_ID, * }) * export class CanvasExample extends Container implements CanvasBaseItem { * get memory(): Memory { * return { * pixivnId: CANVAS_EXAMPLE_ID, * // ... other properties * } * } * async setMemory(value: Memory) { * // ... set other properties * } * } * ``` */ declare class CanvasBaseItem { constructor(..._options: any); /** * This method return the memory of the canvas element. * @throws {PixiError} when the method is not overridden in the subclass. */ get memory(): T2; /** * This method set the memory of the canvas element. * @throws {PixiError} when the method is not overridden in the subclass. */ setMemory(_value: T2): Promise | void; /** * Get the id of the canvas element. This variable is used in the system to get the canvas element by id */ pixivnId: string; } /** * Interface for the canvas base memory */ interface CanvasBaseItemMemory { pixivnId: string; /** * The index of the container in its parent, if it has one */ index?: number; /** * The label of the parent container, if it has one */ parentLabel?: string; label?: string; zIndex?: number; } interface CanvasBaseInterface extends CanvasBaseItem, Container$1 { } /** * Interface exported canvas */ interface CanvasGameState { tickers: { [id: string]: TickerHistory; }; tickersSteps: { [alias: string]: { [tickerId: string]: TickersSequence; }; }; elements: { [alias: string]: CanvasBaseItemMemory; }; stage: Partial; /** * @deprecated */ elementAliasesOrder: string[]; tickersToCompleteOnStepEnd: { tikersIds: { id: string; }[]; stepAlias: { id: string; alias: string; }[]; }; } interface CanvasManagerInterface { /** * The PIXI Application instance. * It not recommended to use this property directly. */ readonly app: Application; /** * The PIXI Container that contains all the canvas elements. * */ readonly gameLayer: Container$1; /** * If the manager is initialized. */ readonly isInitialized: boolean; /** * The width of the canvas. */ width: number; /** * The height of the canvas. */ height: number; /** * The screen of the canvas ({@link Application.screen}). */ readonly screen: Rectangle$1; /** * Initialize the PixiJS Application and the interface div. * This method should be called before any other method. * @param element The html element where I will put the canvas. Example: document.body * @param width The width of the canvas * @param height The height of the canvas * @param options The options of PixiJS Application * @param devtoolsOptions The options of the devtools. You can read more about it in the [PixiJS Devtools documentation](https://pixijs.io/devtools/docs/plugin/) * @example * ```typescript * const body = document.body * if (!body) { * throw new Error('body element not found') * } * await canvas.init(body, { * width: 1920, * height: 1080, * backgroundColor: "#303030" * }) * ``` */ init(element: HTMLElement, options: Partial & { /** * The id of the canvas element. * @default "pixi-vn-canvas" */ id?: string; /** * The resize mode of the canvas. * @default "contain" */ resizeMode?: "contain" | "none"; }, devtoolsOptions?: Devtools): Promise; /** * The children of the canvas. */ readonly children: ContainerChild$1[]; /** * Copy the properties of an old canvas element to a new canvas element. * @param oldAlias Old alias * @param newAlias New alias * @param options The options of the copy. * @returns */ copyCanvasElementProperty(oldAlias: T | CanvasBaseInterface | string, newAlias: CanvasBaseInterface | string, options?: { /** * If provided, the properties returned by this function will not be copied from the old canvas element to the new canvas element. * @param defaultProperties The default properties that will be ignored. * @returns The properties that will be ignored. */ ignoreProperties?: (defaultProperties: string[]) => string[]; }): Promise; /** * Transfer the tickers from an old alias to a new alias. * @param oldAlias Old alias * @param newAlias New alias * @param mode If "move", the old alias will be removed from the ticker. If "duplicate", the old alias will be kept in the ticker. */ transferTickers(oldAlias: string, newAlias: string, mode?: "move" | "duplicate"): void; /** * Add a canvas element to the canvas. * If there is a canvas element with the same alias, all "style", zIndex, and {@link TickerBase} will be transferred to the new canvas element, * and the old canvas element will be removed. * @param alias The alias of the canvas element. * @param canvasComponent The canvas elements to be added. * @param options The options of the canvas element. * @example * ```typescript * const texture = await Assets.load('https://pixijs.com/assets/bunny.png'); * const sprite = Sprite.from(texture); * canvas.add("bunny", sprite); * ``` */ add(alias: string, canvasComponent: CanvasBaseInterface, options?: { /** * If there is a canvas element with the same alias, the "style" of the old canvas element will be imported to the new canvas element. * @default false */ ignoreOldStyle?: boolean; /** * The zIndex of the canvas element. * @default undefined */ zIndex?: number; }): void; /** * Remove a canvas element from the canvas. * And remove all tickers that are not connected to any canvas element. * @param alias The alias of the canvas element to be removed. * @param options The options of the canvas element. * @returns * @example * ```typescript * canvas.remove("bunny"); * ``` */ remove(alias: string | string[], options?: { /** * If true, the tickers that are connected to the canvas element will not be removed. * @default false */ ignoreTickers?: boolean; }): void; /** * Get a canvas element by the alias. * @param alias The alias of the canvas element. * @returns The canvas element. * @example * ```typescript * const sprite = canvas.find("bunny"); * ``` */ find>(alias: string): T | undefined; /** * Check if a DisplayObject is on the canvas. * @param pixiElement The DisplayObject to be checked. * @returns If the DisplayObject is on the canvas. */ canvasElementIsOnCanvas(pixiElement: T): boolean; /** * Remove all canvas elements from the canvas. */ removeAll(): void; /** * Edit the alias of a canvas element. The tickers that are connected to the canvas element will be transferred. * @param oldAlias The old alias of the canvas element. * @param newAlias The new alias of the canvas element. * @param options The options of the canvas element. */ editAlias(oldAlias: string, newAlias: string, options?: { /** * If true, the tickers that are connected to the canvas element will not be transferred. * @default false */ ignoreTickers?: boolean; }): void; /** Edit Tickers Methods */ /** * Currently tickers that are running. */ readonly currentTickers: Map>; /** * The steps of the tickers */ readonly currentTickersSteps: Map>; /** * Find a ticker by its id. * @param tickerId The id of the ticker. * @param args The args of the ticker. * @returns The ticker if found, undefined otherwise. */ findTicker(tickerId: string, args?: TArgs): Ticker | undefined; /** * Run a ticker. You can run multiple addTicker with the same alias and different tickerClasses. * If you run a ticker with the same alias and tickerClass, the old ticker will be removed. * If already exists a sequence of tickers with the same alias, it will be removed. * @param canvasElementAlias The alias of the canvas element that will use the ticker. * @param ticker The ticker class to be run. * @returns The id of the ticker. * @example * ```typescript * canvas.addTicker("alien", new RotateTicker({ speed: 0.2 })) * ``` */ addTicker(canvasElementAlias: string | string[], ticker: Ticker): string | undefined; /** * Run a sequence of tickers. * @param alias The alias of canvas element that will use the tickers. * @param steps The steps of the tickers. * @param currentStepNumber The current step number. It is used to continue the sequence of tickers. * @returns The id of tickers. * @example * ```typescript * canvas.addTickersSequence("alien", [ * new RotateTicker({ speed: 0.1, clockwise: true }, 2), // 2 seconds * Pause(1), // 1 second * new RotateTicker({ speed: 0.2, clockwise: false }, 2), * Repeat, * ]) * ``` */ addTickersSequence(alias: string, steps: (Ticker | RepeatType | PauseType)[], currentStepNumber?: number): string | undefined; /** * Remove a connection between a canvas element and a ticker. * And remove the ticker if there is no canvas element connected to it. * @param alias The alias of the canvas element that will use the ticker. * @param ticker The ticker class to be removed. * @example * ```typescript * canvas.unlinkComponentFromTicker("alien", RotateTicker) * ``` * @deprecated */ unlinkComponentFromTicker(alias: string | string[], ticker?: { new (): Ticker; } | string): void; /** * Remove all tickers from the canvas. */ removeAllTickers(): void; /** * Remove a ticker by the id. * @param tickerId The id of the ticker. */ removeTicker(tickerId: string | string[]): void; /** * Pause a ticker. If a paused ticker have a time to be removed, it will be removed after the time. * @param filters The filters to pause the ticker. * @returns The ids of the paused tickers. */ pauseTicker(filters: { /** * The alias of the canvas element that will use the ticker. * Will pause all tickers that are connected to this canvas element. */ canvasAlias: string; /** * Ticker ids excluded from the pause. If not provided, all tickers will be paused. */ tickerIdsExcluded?: string[]; } | { /** * The id of the ticker to be paused. If provided, only this ticker will be paused. */ id: string | string[]; }): string[]; /** * Resume a ticker. * @param filters The filters to resume the ticker. */ resumeTicker(filters: { /** * The alias of the canvas element that will use the ticker. * Will resume all tickers that are connected to this canvas element. */ canvasAlias: string; } | { /** * The id of the ticker to be resumed. If provided, only this ticker will be resumed. */ id: string | string[]; }): void; /** * @deprecated Use {@link findTicker}(id).paused * Check if a ticker is paused. * @param alias The alias of the canvas element that will use the ticker. * @param tickerId The ticker that will be checked. * @returns If the ticker is paused. */ isTickerPaused(alias: string, tickerId?: string): boolean; /** * Pause the rendering of gameLayer and pause currently running tickers. * Use {@link resume} to restore rendering and resume only * the tickers paused by this method. */ pause(): void; /** * Resume the rendering of gameLayer and resume tickers that were paused by * {@link pause}. */ resume(): void; /** * Add a ticker that must be completed before the next step. * This method is used for example into a transition between scenes. * @param step The step that the ticker must be completed before the next step. */ completeTickerOnStepEnd(step: { /** * The id of the step. */ id: string; /** * If is a sequence of tickers, the alias of the sequence of tickers. */ alias?: string; }): void; /** * This method force the completion of the tickers that are running. * This funcions is called in the next step. * @param id The id of the ticker. If the alias provided, the id is the id of the sequence of tickers. * @param alias The alias of the sequence of tickers. */ forceCompletionOfTicker(id: string, alias?: string): Promise; /** * Animate a Pixi’VN component or components using [motion's animate](https://motion.dev/docs/animate) function. * This function integrates with the PixiJS ticker to ensure smooth animations. * * Pixi’VN will keep track of the animation state of this function. * So Pixi’VN will save the animation state in saves. * @param components - The PixiJS component(s) to animate. * @param keyframes - The keyframes to animate the component(s) with. * @param options - Additional options for the animation, including duration, easing, and ticker. * @param priority - The priority of the ticker. @default UPDATE_PRIORITY.NORMAL * @returns The id of tickers. * @template T - The type of Pixi’VN component(s) being animated. */ animate>(components: T | string | (string | T)[], keyframes: KeyframesType, options?: AnimationOptions, priority?: UPDATE_PRIORITY$1): string | undefined; /** * Animate a Pixi’VN component or components using [motion's animate](https://motion.dev/docs/animate) function. * This function integrates with the PixiJS ticker to ensure smooth animations. * * Pixi’VN will keep track of the animation state of this function. * So Pixi’VN will save the animation state in saves. * @param components - The PixiJS component(s) to animate. * @param sequence - The sequence of keyframes to animate the component(s) with. * @param options - Additional options for the animation, including duration, easing, and ticker. * @param priority - The priority of the ticker. @default UPDATE_PRIORITY.NORMAL * @returns The id of tickers. * @template T - The type of Pixi’VN component(s) being animated. */ animate>(components: T | string, sequence: (ObjectSegment | ObjectSegmentWithTransition)[], options?: SequenceOptions, priority?: UPDATE_PRIORITY$1): string | undefined; /** * Add a layer to the canvas. * @param label The label of the layer. * @param layer The layer to be added. * @returns The layer. * @example * ```typescript * const uiLayer = new Container(); * canvas.addLayer("ui", uiLayer); * ``` */ addLayer(label: string, layer: Container$1): Layer | undefined; /** * Get a layer from the canvas. * @param label The label of the layer. * @returns The layer. * @example * ```typescript * const uiLayer = canvas.getLayer("ui"); * ``` */ getLayer(label: string): Layer | null; /** * Remove a layer from the canvas. * @param label The label of the layer to be removed. * @example * ```typescript * canvas.removeLayer("ui"); * ``` */ removeLayer(label: string): void; /** * Add a HTML layer to the canvas. * @param id The id of the layer. * @param element The html element to be added. * @param style The style of the layer. @default { position: "absolute", pointerEvents: "none", userSelect: "none" }. * @example * ```tsx * const root = document.getElementById('root') * if (!root) { * throw new Error('root element not found') * } * const htmlLayer = canvas.addHtmlLayer("ui", root, { * position: "absolute", * pointerEvents: "none" * }) * const reactRoot = createRoot(htmlLayer) * reactRoot.render( * * ) * ``` */ addHtmlLayer(id: string, element: HTMLElement, style?: Partial>): HTMLDivElement; /** * Get a HTML layer from the canvas. * @param id The id of the layer to be removed. */ removeHtmlLayer(id: string): void; /** * Get a HTML layer from the canvas. * @param id The id of the layer. */ getHtmlLayer(id: string): HTMLElement | undefined; /** * Extract the canvas as an image. * @returns The image as a base64 string. */ extractImage(): Promise; /** * Clear the canvas and the tickers. */ clear(): void; /** * Export the canvas and the tickers to an object. * @returns The object. */ export(): CanvasGameState; /** * Restore the canvas and the tickers from an object. * @param data The object. */ restore(data: object): Promise; onTickerComplete(tickerId: string, options: { aliasToRemoveAfter: string[]; tickerAliasToResume: string[]; tickerIdToResume: string[]; ignoreTickerSteps?: boolean; stopTicker?: boolean; }): void; } interface AdditionalPositionsExtensionProps { /** * is a way to set the position of the element in the canvas. compared to position, align, it is a percentage used to determine the proximity from the edges of the canvas. * For example: * - if you set align to 0.5, the element will be in the center of the canvas. * - if you set align to 0, the left end and a top end of the element will be in the left end and top end of the canvas. * - if you set align to 1, the right end and a bottom end of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does not affect the alignment. */ align?: Partial | number; /** * is a way to set the position of the element in the canvas. compared to position, align, it is a percentage used to determine the proximity from the edges of the canvas. * For example: * - if you set align to 0.5, the element will be in the center of the canvas. * - if you set align to 0, the left end and a top end of the element will be in the left end and top end of the canvas. * - if you set align to 1, the right end and a bottom end of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does not affect the alignment. */ xAlign?: number; /** * is a way to set the position of the element in the canvas. compared to position, align, it is a percentage used to determine the proximity from the edges of the canvas. * For example: * - if you set align to 0.5, the element will be in the center of the canvas. * - if you set align to 0, the left end and a top end of the element will be in the left end and top end of the canvas. * - if you set align to 1, the right end and a bottom end of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does not affect the alignment. */ yAlign?: number; /** * is a way to set the position of the element in the canvas calculated in percentage. * For example, if you set the {@link PixiContainer.pivot} to 0.5, and: * - if you set percentagePosition to 0.5, the element will be in the center of the canvas. * - If you set percentagePosition to 0, the center of the element will be in the left end and top end of the canvas. * - If you set percentagePosition to 1, the center of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does affect the percentagePosition. */ percentagePosition?: Partial | number; /** * is a way to set the position of the element in the canvas calculated in percentage. * For example, if you set the {@link PixiContainer.pivot} to 0.5, and: * - if you set percentagePosition to 0.5, the element will be in the center of the canvas. * - If you set percentagePosition to 0, the center of the element will be in the left end and top end of the canvas. * - If you set percentagePosition to 1, the center of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does affect the percentagePosition. */ percentageX?: number; /** * is a way to set the position of the element in the canvas calculated in percentage. * For example, if you set the {@link PixiContainer.pivot} to 0.5, and: * - if you set percentagePosition to 0.5, the element will be in the center of the canvas. * - If you set percentagePosition to 0, the center of the element will be in the left end and top end of the canvas. * - If you set percentagePosition to 1, the center of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does affect the percentagePosition. */ percentageY?: number; } interface AdditionalPositionsExtension { /** * is a way to set the position of the element in the canvas. compared to position, align, it is a percentage used to determine the proximity from the edges of the canvas. * For example: * - if you set align to 0.5, the element will be in the center of the canvas. * - if you set align to 0, the left end and a top end of the element will be in the left end and top end of the canvas. * - if you set align to 1, the right end and a bottom end of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does not affect the alignment. */ align: Partial | number; /** * is a way to set the position of the element in the canvas. compared to position, align, it is a percentage used to determine the proximity from the edges of the canvas. * For example: * - if you set align to 0.5, the element will be in the center of the canvas. * - if you set align to 0, the left end and a top end of the element will be in the left end and top end of the canvas. * - if you set align to 1, the right end and a bottom end of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does not affect the alignment. */ xAlign: number; /** * is a way to set the position of the element in the canvas. compared to position, align, it is a percentage used to determine the proximity from the edges of the canvas. * For example: * - if you set align to 0.5, the element will be in the center of the canvas. * - if you set align to 0, the left end and a top end of the element will be in the left end and top end of the canvas. * - if you set align to 1, the right end and a bottom end of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does not affect the alignment. */ yAlign: number; /** * is a way to set the position of the element in the canvas calculated in percentage. * For example, if you set the {@link PixiContainer.pivot} to 0.5, and: * - if you set percentagePosition to 0.5, the element will be in the center of the canvas. * - If you set percentagePosition to 0, the center of the element will be in the left end and top end of the canvas. * - If you set percentagePosition to 1, the center of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does affect the percentagePosition. */ percentagePosition: Partial | number; /** * is a way to set the position of the element in the canvas calculated in percentage. * For example, if you set the {@link PixiContainer.pivot} to 0.5, and: * - if you set percentagePosition to 0.5, the element will be in the center of the canvas. * - If you set percentagePosition to 0, the center of the element will be in the left end and top end of the canvas. * - If you set percentagePosition to 1, the center of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does affect the percentagePosition. */ percentageX: number; /** * is a way to set the position of the element in the canvas calculated in percentage. * For example, if you set the {@link PixiContainer.pivot} to 0.5, and: * - if you set percentagePosition to 0.5, the element will be in the center of the canvas. * - If you set percentagePosition to 0, the center of the element will be in the left end and top end of the canvas. * - If you set percentagePosition to 1, the center of the element will be in the right end and bottom end of the canvas. * * **Important:** The {@link PixiContainer.pivot} field does affect the percentagePosition. */ percentageY: number; readonly positionType: "pixel" | "percentage" | "align"; readonly positionInfo: { x: number; y: number; type: "pixel" | "percentage" | "align"; }; } declare function analizePositionsExtensionProps(props?: T): T | undefined; interface AnchorExtensionProps { anchor?: PointData | number; } interface AnchorExtension { /** * The anchor sets the origin point of the imageContainer. The default value is taken from the {@link Texture} * and passed to the constructor. * * The default is `(0,0)`, this means the imageContainer's origin is the top left. * * Setting the anchor to `(0.5,0.5)` means the imageContainer's origin is centered. * * Setting the anchor to `(1,1)` would mean the imageContainer's origin point will be the bottom right corner. * * If you pass only single parameter, it will set both x and y to the same value as shown in the example below. * @example * import { ImageContainer } from '@drincs/pixi-vn'; * * const imageContainer = new ImageContainer(); * imageContainer.anchor = 0.5; */ anchor: PointData; } type ContainerChild = Container$1 & CanvasBaseItem; interface ContainerOptions extends Omit, "on">, AnchorExtensionProps, AdditionalPositionsExtensionProps { } interface SpriteOptions extends Omit, AdditionalPositionsExtensionProps { } interface TextOptions extends Omit, AdditionalPositionsExtensionProps { } interface ImageContainerOptions extends ContainerOptions { } interface ImageSpriteOptions extends SpriteOptions { } interface VideoSpriteOptions extends ImageSpriteOptions { loop?: boolean; paused?: boolean; currentTime?: number; } interface ListenerExtensionMemory { onEvents?: OnEventsHandlers; } interface OnEventsHandlers { [name: string]: string; } interface ListenerExtension { /** * Add a listener for a given event. * @example * ```ts * export class Events { * \@eventDecorator() * static eventExample(event: FederatedEvent, component: Sprite) { * // event code here * } * } * * sprite.on("pointerdown", Events.eventExample); * ``` */ on: Container$1["on"]; readonly onEventsHandlers: OnEventsHandlers; } declare function addListenerHandler(event: symbol | string, element: T, fn: (...args: never[]) => unknown): boolean; /** * Interface for Asset memory */ interface AssetMemory { /** * @deprecated */ image?: string; alias?: string; url: string; } interface SpriteBaseMemory extends SpriteOptions$1, CanvasBaseItemMemory, ListenerExtensionMemory, AdditionalPositionsExtensionProps { textureData?: AssetMemory; } /** * Interface for the canvas sprite memory */ interface SpriteMemory extends SpriteBaseMemory { } /** * This class is a extension of the [PIXI.Sprite class](https://pixijs.com/8.x/examples/sprite/basic), it has the same properties and methods, * but it has the ability to be saved and loaded by the Pixi’VN library. * @example * ```typescript * const texture = await Assets.load('https://pixijs.com/assets/bunny.png'); * const sprite = Sprite.from(texture); * * sprite.anchor.set(0.5); * sprite.x = canvas.screen.width / 2; * sprite.y = canvas.screen.height / 2; * * sprite.eventMode = 'static'; * sprite.cursor = 'pointer'; * sprite.onEvent('pointerdown', EventTest); * * canvas.add("bunny", sprite); * ``` */ declare class Sprite extends _drincs_pixi_vn_pixi_js__default.Sprite implements CanvasBaseItem, ListenerExtension, AdditionalPositionsExtension { constructor(options?: SpriteOptions | Texture$1); readonly pixivnId: string; get memory(): Memory | SpriteMemory; setMemory(value: Memory | SpriteMemory): Promise; static from(source: Texture$1 | TextureSourceLike, skipCache?: boolean): Sprite; /** ListenerExtension */ readonly onEventsHandlers: OnEventsHandlers; on | keyof { [K: symbol]: any; [K: {} & string]: any; }>(event: T, fn: (...args: [ ...EventEmitter.ArgumentMap & { [K: symbol]: any; [K: {} & string]: any; }>[Extract | keyof { [K: symbol]: any; [K: {} & string]: any; }>], typeof this ]) => void, context?: any): this; /** AdditionalPositionsExtension */ private _align; set align(value: Partial | number); get align(): Partial | number; set xAlign(value: number); get xAlign(): number; set yAlign(value: number); get yAlign(): number; private _percentagePosition; set percentagePosition(value: Partial | number); get percentagePosition(): Partial | number; get percentageX(): number; set percentageX(_value: number); get percentageY(): number; set percentageY(_value: number); get positionType(): "pixel" | "percentage" | "align"; get positionInfo(): { x: number; y: number; type: "pixel" | "percentage" | "align"; }; set positionInfo(value: { x: number; y: number; type?: "pixel" | "percentage" | "align"; }); protected reloadPosition(): void; get position(): ObservablePoint; set position(value: ObservablePoint); get x(): number; set x(value: number); get y(): number; set y(value: number); } /** * The memory of the image. It uses for save the state of the image. */ interface ImageSpriteMemory extends SpriteBaseMemory { loadIsStarted: boolean; } /** * This class is a extension of the {@link Sprite} class, it has the same properties and methods, * but it has some features that make texture management easier. * You need to use {@link load} to show the image in the canvas. * This class is used for functions like {@link addImage} and {@link showWithDissolve}. * @example * ```typescript * let alien = new ImageSprite({ * anchor: { x: 0.5, y: 0.5 }, * x: 100, * y: 100, * }, 'https://pixijs.com/assets/eggHead.png') * await alien.load() * canvas.add("alien", alien) * ``` * @example * ```typescript * let alien = addImage("alien", 'https://pixijs.com/assets/eggHead.png') * alien.anchor.set(0.5); * alien.x = 100 * alien.y = 100 * await alien.load() * ``` */ declare class ImageSprite extends Sprite { private _textureAlias?; protected get textureAlias(): string; readonly pixivnId: string; constructor(options?: ImageSpriteOptions | Omit | undefined, textureAlias?: string); get memory(): ImageSpriteMemory; setMemory(memory: Memory | SpriteMemory): Promise; static from(source: Texture$1 | TextureSourceLike, skipCache?: boolean): ImageSprite; private _loadIsStarted; get loadIsStarted(): boolean; /** * Load the image from the link and set the texture of the sprite. * @returns A promise that resolves when the image is loaded. */ load(): Promise; set texture(value: Texture$1>); get texture(): Texture$1>; /** * Check if the texture is empty. * @returns A boolean that is true if the texture is empty. */ get haveEmptyTexture(): boolean; } /** * The memory of the video. It uses for save the state of the video. */ interface VideoSpriteMemory extends ImageSpriteMemory { loop: boolean; paused: boolean; currentTime: number; } /** * This class is a extension of the {@link ImageSprite} class, it has the same properties and methods, * but it has some features that make video management easier. * You need to use {@link load} to show the video in the canvas. * This class is used for functions like {@link addVideo} and {@link showWithDissolve}. * @example * ```typescript * let film = new VideoSprite({ * x: 100, * y: 100, * }, 'https://pixijs.com/assets/video.mp4') * await film.load() * canvas.add("film", film) * ``` * @example * ```typescript * let film = addVideo("film", 'https://pixijs.com/assets/video.mp4') * film.currentTime = 2 * await film.load() * ``` */ declare class VideoSprite extends ImageSprite { constructor(options?: VideoSpriteOptions | Texture$1 | undefined, textureAlias?: string); readonly pixivnId: string; get memory(): VideoSpriteMemory; setMemory(value: VideoSpriteMemory): Promise; static from(source: Texture$1 | TextureSourceLike, skipCache?: boolean): VideoSprite; load(): Promise; private _looop; /** * Set to true if you want the video to loop. */ get loop(): boolean; set loop(value: boolean); private _paused; /** * Set to true if you want the video to be paused. */ get paused(): boolean; set paused(value: boolean); /** * Pause the video. */ pause(): void; /** * Play the video. */ play(): void; private _currentTime; /** * The current time of the video. */ get currentTime(): number; set currentTime(value: number); /** * Restart the video. */ restart(): void; /** * The duration of the video. */ get duration(): number | undefined; } /** * Interface for the canvas container memory */ interface ContainerMemory extends ContainerOptions$1, CanvasBaseItemMemory, ListenerExtensionMemory, AdditionalPositionsExtensionProps { /** * The elements contained in this container */ elements: CanvasBaseItemMemory[]; } /** * This class is a extension of the [PIXI.Container class](https://pixijs.com/8.x/examples/basic/container), it has the same properties and methods, * but it has the ability to be saved and loaded by the Pixi’VN library. * @example * ```typescript * const container = new Container(); * canvas.add(container); * const texture = await Assets.load('https://pixijs.com/assets/bunny.png'); * for (let i = 0; i < 25; i++) * { * const bunny = new Sprite(texture); * bunny.x = (i % 5) * 40; * bunny.y = Math.floor(i / 5) * 40; * container.addChild(bunny); * } * ``` */ declare class Container extends Container$1 implements CanvasBaseItem, ListenerExtension, AnchorExtension, AdditionalPositionsExtension { constructor(options?: ContainerOptions); readonly pixivnId: string; get memory(): Memory; setMemory(value: Memory): Promise; protected importChildren(value: Memory): Promise; /** ListenerExtension */ readonly onEventsHandlers: OnEventsHandlers; on | keyof { [K: symbol]: any; [K: {} & string]: any; }>(event: T, fn: (...args: [ ...EventEmitter.ArgumentMap & { [K: symbol]: any; [K: {} & string]: any; }>[Extract | keyof { [K: symbol]: any; [K: {} & string]: any; }>], typeof this ]) => void, context?: any): this; /** Anchor */ private _anchor?; get anchor(): PointData; set anchor(value: PointData | number); protected reloadAnchor(): void; get pivot(): ObservablePoint; set pivot(value: ObservablePoint); /** AdditionalPositions */ private _align; set align(value: Partial | number); get align(): Partial | number; set xAlign(value: number); get xAlign(): number; set yAlign(value: number); get yAlign(): number; private _percentagePosition; set percentagePosition(value: Partial | number); get percentagePosition(): Partial | number; set percentageX(_value: number); get percentageX(): number; set percentageY(_value: number); get percentageY(): number; get positionType(): "pixel" | "percentage" | "align"; get positionInfo(): { x: number; y: number; type: "pixel" | "percentage" | "align"; }; set positionInfo(value: { x: number; y: number; type?: "pixel" | "percentage" | "align"; }); protected reloadPosition(): void; get position(): ObservablePoint; set position(value: ObservablePoint); get x(): number; set x(value: number); get y(): number; set y(value: number); } /** * Interface for the canvas container memory */ interface ImageContainerMemory extends ContainerMemory { elements: ImageSpriteMemory[]; anchor?: PointData; loadIsStarted: boolean; } /** * This class is a extension of the {@link Container}, it has the same properties and methods, * but this container is composed only of {@link ImageSprite} and introduces the {@link load} functionality * @example * ```typescript * const liamBodyImageUrl = 'https://example.com/assets/liam/body.png'; * const liamHeadImageUrl = 'https://example.com/assets/liam/head.png'; * const container = new ImageContainer(undefined, [liamBodyImageUrl, liamHeadImageUrl]); * await container.load() * canvas.add(container); * ``` */ declare class ImageContainer extends Container { constructor(options?: ImageContainerOptions, textureAliases?: string[]); get memory(): ImageContainerMemory; setMemory(value: ImageContainerMemory): Promise; readonly pixivnId: string; private _loadIsStarted; get loadIsStarted(): boolean; /** * Load the children images. * @returns A promise that resolves when the images are loaded. */ load(): Promise; /** * The texture of the first child. * If there is no child, it returns a new {@link Texture}. */ get texture(): Texture$1<_drincs_pixi_vn_pixi_js.TextureSource>; /** * Check if there is a child with the empty texture. * @returns A boolean that is true if there is a child with the empty texture. */ get haveEmptyTexture(): boolean; } /** * This class is responsible for managing the canvas, the tickers, the events, and the window size and the children of the window. */ declare class CanvasManagerStatic { private constructor(); private static _app; /** * The Pixi.js application instance. * @throws {PixiError} when the canvas has not been initialized yet (i.e. before calling `Game.init()`). */ static get app(): Application<_drincs_pixi_vn_pixi_js.Renderer>; static get gameLayer(): _drincs_pixi_vn_pixi_js.Container<_drincs_pixi_vn_pixi_js.ContainerChild>; /** * This is the div that have same size of the canvas. * This is useful to put interface elements. * You can use React or other framework to put elements in this div. */ static htmlLayers: HTMLElement[]; static canvasWidth: number; static canvasHeight: number; static _isInitialized: boolean; static init(element: HTMLElement, options?: Partial & { /** * The id of the canvas element. * @default "pixi-vn-canvas" */ id?: string; /** * The resize mode of the canvas. * @default "contain" */ resizeMode?: "contain" | "none"; }, devtoolsOptions?: Devtools): Promise; /** * Add the canvas into a html element. * @param element it is the html element where I will put the canvas. Example: document.body * @param id it is the id of the canvas element. */ private static addCanvasIntoHTMLElement; static addHtmlLayer(id: string, element: HTMLElement, style?: Partial>): HTMLDivElement; static removeHtmlLayer(id: string): void; static getHtmlLayer(id: string): HTMLElement | undefined; /** * This method is called when the screen is resized. */ private static resize; /** * The order of the elements in the canvas, is determined by the zIndex. */ static get childrenAliasesOrder(): string[]; /** Edit Tickers Methods */ static get currentTickersWithoutCreatedBySteps(): { [k: string]: TickerHistory; }; static readonly _currentTickers: Map>; static readonly _currentTickersSequence: Map>; static get currentTickersSequence(): { [alias: string]: { [tickerId: string]: TickersSequence; }; }; static readonly _currentTickersTimeouts: Map; static readonly _tickersToCompleteOnStepEnd: { tikersIds: { id: string; }[]; stepAlias: { id: string; alias: string; }[]; }; static generateTickerId(...args: any[]): string; static addTickerTimeoutInfo(aliases: string | string[], ticker: string, timeout: string, canBeDeletedBeforeEnd: boolean): void; static removeTickerTimeoutInfo(timeout: NodeJS.Timeout | string): void; static removeTickerTimeout(timeout: NodeJS.Timeout | string): void; static removeTickerTimeoutsByAlias(alias: string, checkCanBeDeletedBeforeEnd: boolean): void; } /** * Interface for the canvas text memory */ interface TextMemory extends TextOptions$1, CanvasBaseItemMemory, AdditionalPositionsExtensionProps, ListenerExtensionMemory { } /** * This class is a extension of the [PIXI.Text class](https://pixijs.com/8.x/examples/text/pixi-text), it has the same properties and methods, * but it has the ability to be saved and loaded by the Pixi’VN library. * @example * ```typescript * const text = new Text(); * text.text = "Hello World" * canvas.add("text", text); * ``` */ declare class Text extends _drincs_pixi_vn_pixi_js__default.Text implements CanvasBaseItem, AdditionalPositionsExtension, ListenerExtension { constructor(options?: TextOptions); readonly pixivnId: string; get memory(): TextMemory; setMemory(value: TextMemory): Promise; readonly onEventsHandlers: OnEventsHandlers; on | keyof { [K: symbol]: any; [K: {} & string]: any; }>(event: T, fn: (...args: [ ...EventEmitter.ArgumentMap & { [K: symbol]: any; [K: {} & string]: any; }>[Extract | keyof { [K: symbol]: any; [K: {} & string]: any; }>], typeof this ]) => void, context?: any): this; /** AdditionalPositions */ private _align; set align(value: Partial | number); get align(): Partial | number; set xAlign(value: number); get xAlign(): number; set yAlign(value: number); get yAlign(): number; private _percentagePosition; set percentagePosition(value: Partial | number); get percentagePosition(): Partial | number; get percentageX(): number; set percentageX(_value: number); get percentageY(): number; set percentageY(_value: number); get positionType(): "pixel" | "percentage" | "align"; get positionInfo(): { x: number; y: number; type: "pixel" | "percentage" | "align"; }; set positionInfo(value: { x: number; y: number; type?: "pixel" | "percentage" | "align"; }); protected reloadPosition(): void; get position(): ObservablePoint; set position(value: ObservablePoint); get x(): number; set x(value: number); get y(): number; set y(value: number); } type CanvasElementAliasType = string; /** * Is a decorator that register a canvas component in the game. * @param options Options for the canvas component. * @returns */ declare function canvasComponentDecorator>(options?: { /** * Name of the canvas component. If the name is already registered, it will show a warning * @default target.name */ name?: CanvasElementAliasType; /** * Function to get the instance of the canvas component. If not set, it will use the default constructor of the class. * This function is used into {@link canvas.restore} to restore the canvas. * @param canvasClass The class of the canvas component. * @param memory Memory of the canvas component. * @returns The instance of the canvas component. */ getInstance?: (canvasClass: T, memory: M) => CanvasBaseItem | Promise>; /** * Function to copy the properties of the canvas component. This function is used when to copy the properties of the canvas component into another instance of the same canvas component. * This function is used into {@link canvas.copyCanvasElementProperty} to copy the properties of the canvas component. * @param component The instance of the canvas component to copy the properties. * @param memory The memory of the canvas component to copy the properties. * @returns */ copyProperty?: (component: CanvasBaseItem, memory: M) => void | Promise; }): (target: T) => void; declare function setMemoryContainer(element: T | Container$1, memory: ContainerOptions$1 | {}, options?: { ignoreScale?: boolean; end?: () => Promise | void; }): Promise; declare namespace RegisteredCanvasComponents { /** * Register a canvas component in the game. * @param target The class of the canvas component. * @param options Options for the canvas component. */ function add>(target: T, options?: { /** * Name of the canvas component. If the name is already registered, it will show a warning * @default target.name */ name?: CanvasElementAliasType; /** * Function to get the instance of the canvas component. If not set, it will use the default constructor of the class. * This function is used into {@link canvas.restore} to restore the canvas. * @param canvasClass The class of the canvas component. * @param memory Memory of the canvas component. * @returns The instance of the canvas component. */ getInstance?: (canvasClass: T, memory: M) => CanvasBaseItem | Promise>; /** * Function to copy the properties of the canvas component. This function is used when to copy the properties of the canvas component into another instance of the same canvas component. * This function is used into {@link canvas.copyCanvasElementProperty} to copy the properties of the canvas component. * @param component The instance of the canvas component to copy the properties. * @param memory The memory of the canvas component to copy the properties. * @returns */ copyProperty?: (component: CanvasBaseItem, memory: M) => void | Promise; }): void; /** * Get a canvas component by the id. * @param canvasId The id of the canvas component. * @returns The canvas component type. */ function get>(canvasId: CanvasElementAliasType): T | undefined; function getInstance>(canvasId: CanvasElementAliasType, memory: M): Promise; function copyProperty(canvasId: CanvasElementAliasType, component: CanvasBaseItem, source: CanvasBaseItemMemory): Promise; /** * Get a list of all canvas components registered. * @returns An array of canvas components. */ function values(): (typeof CanvasBaseItem)[]; /** * Check if a canvas component is registered. * @param id The id of the canvas component. * @returns True if the canvas component is registered, false otherwise. */ function has(id: string): boolean; /** * Get a list of all canvas component ids registered. * @returns An array of label ids. */ function keys(): string[]; } type SerializableEventHandler = (...args: never[]) => unknown; /** * Is a decorator that register a event in the game. * Is a required decorator for use the event in the game. * Thanks to this decoration the game has the possibility of updating the events to the latest modification and saving the game. * @example * ```ts * export class Events { * \@eventDecorator() * static eventExample(event: FederatedEvent, component: Sprite) { * // event code here * } * } * * sprite.on("pointerdown", Events.eventExample); * ``` * @param name is th identifier of the event, by default is the name of the class * @returns */ declare function eventDecorator(name?: string): (_target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void; declare namespace RegisteredEvents { /** * Register a event in the game. * @param fn The class of the event. * @param name Name of the event, by default it will use the class name. If the name is already registered, it will show a warning */ function add(fn: SerializableEventHandler, name: string): void; /** * Get a event by the id. * @param canvasId The id of the event. * @returns The event type. */ function get(name: string): SerializableEventHandler | undefined; /** * Get a list of all events registered. * @returns An array of events. */ function values(): SerializableEventHandler[]; /** * Check if a event is registered. * @param id The id of the event. * @returns True if the event is registered, false otherwise */ function has(id: string): boolean; /** * Get a list of all event ids registered. * @returns An array of label ids. */ function keys(): string[]; } /** * Shake the canvas element. * If there is a/more ticker(s) with the same alias, then the ticker(s) is/are paused. * @param alias * @param options * @param priority * @returns */ declare function shakeEffect(alias: string, options?: ShakeEffectProps, priority?: UPDATE_PRIORITY$1): Promise; declare namespace CanvasPropertyUtility { function calculatePositionByAlign(type: "width" | "height", align: number, value: number, pivot: number, negativeScale: boolean, anchor?: number): number; function calculateAlignByPosition(type: "width" | "height", position: number, value: number, pivot: number, negativeScale: boolean, anchor?: number): number; function calculatePositionByPercentagePosition(type: "width" | "height", percentage: number): number; function calculatePercentagePositionByPosition(type: "width" | "height", position: number): number; function getSuperPoint(point: { x: number; y: number; }, angle: number): { x: number; y: number; }; function getPointBySuperPoint(superPoint: { x: number; y: number; }, angle: number): { x: number; y: number; }; function getSuperWidth(canvasElement: Container$1): number; function getSuperHeight(canvasElement: Container$1): number; } interface BaseTransitionProps { /** * @deprecated Use {@link completeOnContinue} instead. */ forceCompleteBeforeNext?: boolean; /** * If true, the transition will be completed before the next step. * For example, if the transition is a dissolve transition, the "alpha" of the texture will be 1 before the next step. * @default true */ completeOnContinue?: boolean; } interface ShowWithDissolveTransitionProps extends BaseTransitionProps, AnimationOptions { } interface ShowWithFadeTransitionProps extends BaseTransitionProps, AnimationOptions { } interface MoveInOutProps extends BaseTransitionProps, AnimationOptions { /** * The direction of the movement. * @default "right" */ direction?: "up" | "down" | "left" | "right"; } interface ZoomInOutProps extends BaseTransitionProps, AnimationOptions { /** * The direction of the zoom effect. * @default "right" */ direction?: "up" | "down" | "left" | "right"; } interface PushInOutProps extends BaseTransitionProps, AnimationOptions { /** * The direction of the push effect. * @default "right" */ direction?: "up" | "down" | "left" | "right"; } type TComponent = CanvasBaseInterface | string | string[] | { value: string; options: ImageSpriteOptions; } | { value: string[]; options: ImageContainerOptions; }; /** * Show a image in the canvas with a disolve effect. * Disolve effect is a effect that the image is shown with a fade in. * If exist a image with the same alias, then the image is replaced and the first image is removed after the effect is done. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param component The imageUrl, array of imageUrl or the canvas component. If imageUrl is a video, then the {@link VideoSprite} is added to the canvas. * If imageUrl is an array, then the {@link ImageContainer} is added to the canvas. * If you don't provide the component, then the alias is used as the url. * @param props The properties of the effect * @param priority The priority of the effect * @returns A promise that contains the ids of the tickers that are used in the effect. The promise is resolved when the image is loaded. */ declare function showWithDissolve(alias: string, component?: TComponent, props?: ShowWithDissolveTransitionProps, priority?: UPDATE_PRIORITY$1): Promise; /** * Remove a image from the canvas with a disolve effect. * Disolve effect is a effect that the image is removed with a fade out. * This function is equivalent to {@link removeWithFade}. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param props The properties of the effect * @param priority The priority of the effect * @returns The ids of the tickers that are used in the effect. */ declare function removeWithDissolve(alias: string, props?: ShowWithDissolveTransitionProps, priority?: UPDATE_PRIORITY$1): string[] | undefined; /** * Show a image in the canvas with a fade effect. * Fade effect is a effect that the image is shown with a fade in. * If exist a image with the same alias, the existing image is removed with a fade transition, and after the effect is done, the new image is shown with a fade transition. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param component The imageUrl, array of imageUrl or the canvas component. If imageUrl is a video, then the {@link VideoSprite} is added to the canvas. * If imageUrl is an array, then the {@link ImageContainer} is added to the canvas. * If you don't provide the component, then the alias is used as the url. * @param props The properties of the effect * @param priority The priority of the effect * @returns A promise that contains the ids of the tickers that are used in the effect. The promise is resolved when the image is loaded. */ declare function showWithFade(alias: string, component?: TComponent, props?: ShowWithFadeTransitionProps, priority?: UPDATE_PRIORITY$1): Promise; /** * Remove a image from the canvas with a fade effect. * Fade effect is a effect that the image is removed with a fade out. * This function is equivalent to {@link removeWithDissolve}. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param props The properties of the effect * @param priority The priority of the effect * @returns The ids of the tickers that are used in the effect. */ declare function removeWithFade(alias: string, props?: ShowWithFadeTransitionProps, priority?: UPDATE_PRIORITY$1): string[] | undefined; /** * Show a image in the canvas with a move effect. The image is moved from outside the canvas to the x and y position of the image. * If there is a/more ticker(s) with the same alias, then the ticker(s) is/are paused. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param component The imageUrl, array of imageUrl or the canvas component. If imageUrl is a video, then the {@link VideoSprite} is added to the canvas. * If imageUrl is an array, then the {@link ImageContainer} is added to the canvas. * If you don't provide the component, then the alias is used as the url. * @param props The properties of the effect * @param priority The priority of the effect * @returns A promise that contains the ids of the tickers that are used in the effect. The promise is resolved when the image is loaded. */ declare function moveIn(alias: string, component?: TComponent, props?: MoveInOutProps & { /** * If true, then the old component is removed with a move out, after the new image is moved in. * @default false */ removeOldComponentWithMoveOut?: boolean; }, priority?: UPDATE_PRIORITY$1): Promise; /** * Remove a image from the canvas with a move effect. The image is moved from the x and y position of the image to outside the canvas. * If there is a/more ticker(s) with the same alias, then the ticker(s) is/are paused. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param props The properties of the effect * @param priority The priority of the effect * @returns The ids of the tickers that are used in the effect. */ declare function moveOut(alias: string, props?: MoveInOutProps, priority?: UPDATE_PRIORITY$1): string[] | undefined; /** * Show a image in the canvas with a zoom effect. The image is zoomed in from the center of the canvas. * If there is a/more ticker(s) with the same alias, then the ticker(s) is/are paused. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param component The imageUrl, array of imageUrl or the canvas component. If imageUrl is a video, then the {@link VideoSprite} is added to the canvas. * If imageUrl is an array, then the {@link ImageContainer} is added to the canvas. * If you don't provide the component, then the alias is used as the url. * @param props The properties of the effect * @param priority The priority of the effect * @returns A promise that contains the ids of the tickers that are used in the effect. The promise is resolved when the image is loaded. */ declare function zoomIn(alias: string, component?: TComponent, props?: ZoomInOutProps & { /** * If true, then the old component is removed with a zoom out, after the new image is zoomed in. * @default false */ removeOldComponentWithZoomOut?: boolean; }, priority?: UPDATE_PRIORITY$1): Promise; /** * Remove a image from the canvas with a zoom effect. The image is zoomed out to the center of the canvas. * If there is a/more ticker(s) with the same alias, then the ticker(s) is/are paused. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param props The properties of the effect * @param priority The priority of the effect * @returns The ids of the tickers that are used in the effect. */ declare function zoomOut(alias: string, props?: ZoomInOutProps, priority?: UPDATE_PRIORITY$1): string[] | undefined; /** * Show a image in the canvas with a push effect. The new image is pushed in from the inside of the canvas and the old image is pushed out to the outside of the canvas. * If there is a/more ticker(s) with the same alias, then the ticker(s) is/are paused. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param component The imageUrl, array of imageUrl or the canvas component. If imageUrl is a video, then the {@link VideoSprite} is added to the canvas. * If imageUrl is an array, then the {@link ImageContainer} is added to the canvas. * If you don't provide the component, then the alias is used as the url. * @param props The properties of the effect * @param priority The priority of the effect * @returns A promise that contains the ids of the tickers that are used in the effect. The promise is resolved when the image is loaded. */ declare function pushIn(alias: string, component?: TComponent, props?: PushInOutProps, priority?: UPDATE_PRIORITY$1): Promise; /** * Remove a image from the canvas with a push effect. The image is pushed out to the outside of the canvas. * If there is a/more ticker(s) with the same alias, then the ticker(s) is/are paused. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param props The properties of the effect * @param priority The priority of the effect * @returns The ids of the tickers that are used in the effect. */ declare function pushOut(alias: string, props?: PushInOutProps, priority?: UPDATE_PRIORITY$1): string[] | undefined; /** * Canvas error handler: when a `PixiError` contains `canvasElementInfo`, * draw a simple `ErrorGraphics` placeholder on the canvas so the scene * remains visible and debuggable. */ declare function drawCanvasErrorHandler(): OnErrorHandler; /** * Add a list of images in the container, after that, the images are added to the canvas. * Is the same that {@link showImageContainer}, but the image is not shown. * If you want to show the image, then you need to use the function {@link ImageSprite.load()}. * @param alias is the unique alias of the image. You can use this alias to refer to this image * @param imageUrls is the url of the image. If you don't provide the url, then the alias is used as the url. * @param options The options of the image. * @returns the container of the image. * @example * ```typescript * let bunny = addImageContainer("bunny", ["https://pixijs.com/assets/bunny-body.png", "https://pixijs.com/assets/bunny-eyes.png"]) * await bunny.load() * ``` */ declare function addImageCointainer(alias: string, imageUrls: string[], options?: ImageContainerOptions): ImageContainer; /** * Add a list of images in the container, after that, the images are added and shown in the canvas. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param imageUrls The url of the image. * @param options The options of the image. * @returns A promise that is resolved when the image is loaded. * @example * ```typescript * let bunny = showImageContainer("bunny", ["https://pixijs.com/assets/bunny-body.png", "https://pixijs.com/assets/bunny-eyes.png"]) * ``` */ declare function showImageContainer(alias: string, imageUrls: string[], options?: ImageContainerOptions): Promise; /** * Add a image in the canvas. * Is the same that {@link showImage}, but the image is not shown. * If you want to show the image, then you need to use the function {@link ImageSprite.load}. * @param alias is the unique alias of the image. You can use this alias to refer to this image * @param imageUrl is the url of the image. If you don't provide the url, then the alias is used as the url. * @param options The options of the image. * @returns the container of the image. * @throws {PixiError} when `imageUrl` is not provided and `alias` is not registered in the asset cache. * @example * ```typescript * let bunny1 = addImage("bunny1", "https://pixijs.com/assets/bunny1.png") * await bunny1.load() * Assets.add({ alias: "bunny2", src: "https://pixijs.com/assets/bunny2.png" }) * let bunny2 = addImage("bunny2") * await bunny2.load() * ``` */ declare function addImage(alias: string, imageUrl?: string, options?: ImageSpriteOptions): ImageSprite; /** * Add and show a image in the canvas. This function is a combination of {@link addImage}. * @param alias The unique alias of the image. You can use this alias to refer to this image * @param imageUrl The url of the image. * @param options The options of the image. * @returns A promise that is resolved when the image is loaded. * @throws {PixiError} when `imageUrl` is not provided and `alias` is not registered in the asset cache. * @example * ```typescript * let bunny1 = showImage("bunny1", "https://pixijs.com/assets/bunny1.png") * Assets.add({ alias: "bunny2", src: "https://pixijs.com/assets/bunny2.png" }) * let bunny2 = showImage("bunny2") * ``` */ declare function showImage(alias: string, imageUrl?: string, options?: ImageSpriteOptions): Promise; /** * Add and show a text in the canvas. * @param alias The unique alias of the text. You can use this alias to refer to this text. * @param text * @param options The options of the text. * @returns A promise that is resolved when the text is loaded. * @example * ```typescript * let text = showText("text", "Hello World", { fontSize: 24, fill: "white" }) * ``` */ declare function showText(alias: string, text: string, options?: Omit): Text; /** * Get a texture from a url. * @param textureAlias is the url of the file. * @returns the texture of the image or video, or `undefined` when `textureAlias` is the `"EMPTY"` sentinel value. * @throws {PixiError} when the alias is missing, the asset is not found in the cache/network, or the loaded resource is not a `Texture`. */ declare function getTexture(textureAlias?: string): Promise; /** * Add a video in the canvas. * Is the same that {@link showVideo}, but the video is not shown. * If you want to show the video, then you need to use the function {@link VideoSprite.load()}. * @param alias is the unique alias of the video. You can use this alias to refer to this video * @param videoUrl is the url of the video. If you don't provide the url, then the alias is used as the url. * @param options The options of the video. * @returns the container of the video. * @throws {PixiError} when `videoUrl` is not provided and `alias` is not registered in the asset cache. * @example * ```typescript * let video1 = addVideo("video1", "https://pixijs.com/assets/video1.mp4") * await video1.load() * Assets.add({ alias: "video2", src: "https://pixijs.com/assets/video2.png" }) * let video2 = addVideo("video2") * await video2.load() * ``` */ declare function addVideo(alias: string, videoUrl?: string, options?: VideoSpriteOptions): VideoSprite; /** * Add and show a video in the canvas. This function is a combination of {@link addVideo}. * @param alias The unique alias of the video. You can use this alias to refer to this video * @param videoUrl The url of the video. * @param options The options of the video. * @returns A promise that is resolved when the video is loaded. * @throws {PixiError} when `videoUrl` is not provided and `alias` is not registered in the asset cache. * @example * ```typescript * let video1 = showVideo("video1", "https://pixijs.com/assets/video1.mp4") * Assets.add({ alias: "video2", src: "https://pixijs.com/assets/video2.png" }) * let video2 = showVideo("video2") * ``` */ declare function showVideo(alias: string, videoUrl?: string, options?: VideoSpriteOptions): Promise; interface ShakeEffectProps extends BaseTransitionProps, AnimationOptions { /** * The number of shocks. **Must be at least 3**. * @default 10 */ shocksNumber?: number; /** * The type of the shake effect * @default "horizontal" */ shakeType?: "horizontal" | "vertical"; /** * The maximum size of the shock. * For horizontal type, it is the maximum size of the x axis. * For vertical type, it is the maximum size of the y axis. * @default 10 */ maxShockSize?: number; } declare const Assets: _drincs_pixi_vn_pixi_js.AssetsClass; declare const Color: typeof _drincs_pixi_vn_pixi_js.Color; declare const Rectangle: typeof _drincs_pixi_vn_pixi_js.Rectangle; declare const TextStyle: typeof _drincs_pixi_vn_pixi_js.TextStyle; declare const Texture: typeof _drincs_pixi_vn_pixi_js.Texture; declare const UPDATE_PRIORITY: typeof _drincs_pixi_vn_pixi_js.UPDATE_PRIORITY; declare const canvas: CanvasManagerInterface; export { type AdditionalPositionsExtension, type AdditionalPositionsExtensionProps, type AnchorExtension, type AnchorExtensionProps, type AssetMemory, Assets, type CanvasBaseInterface, CanvasBaseItem, type CanvasBaseItemMemory, type CanvasGameState, type CanvasManagerInterface, CanvasManagerStatic, CanvasPropertyUtility, Color, type CommonTickerProps, Container, type ContainerChild, type ContainerMemory, type ContainerOptions, ImageContainer, type ImageContainerMemory, type ImageContainerOptions, ImageSprite, type ImageSpriteMemory, type ImageSpriteOptions, type Layer, type ListenerExtension, type ListenerExtensionMemory, type MoveInOutProps, type OnEventsHandlers, type PauseType, type PushInOutProps, Rectangle, RegisteredCanvasComponents, RegisteredEvents, RegisteredTickers, type RepeatType, type ShakeEffectProps, type ShowWithDissolveTransitionProps, type ShowWithFadeTransitionProps, Sprite, type SpriteBaseMemory, type SpriteMemory, type SpriteOptions, Text, type TextMemory, type TextOptions, TextStyle, Texture, type Ticker, type TickerArgs, TickerBase, type TickerHistory, type TickerInfo, type TickerProgrationExponential, type TickerProgrationLinear, type TickerProgrationType, type TickerTimeoutHistory, type TickersSequence, UPDATE_PRIORITY, VideoSprite, type VideoSpriteMemory, type VideoSpriteOptions, type ZoomInOutProps, addImage, addImageCointainer, addListenerHandler, addVideo, analizePositionsExtensionProps, canvas, canvasComponentDecorator, drawCanvasErrorHandler, eventDecorator, getTexture, moveIn, moveOut, pushIn, pushOut, removeWithDissolve, removeWithFade, setMemoryContainer, shakeEffect, showImage, showImageContainer, showText, showVideo, showWithDissolve, showWithFade, tickerDecorator, zoomIn, zoomOut };