import { TickerHistory, TickersSequence } from '@drincs/pixi-vn/tickers'; import { PointData, Container, ContainerOptions } from '@drincs/pixi-vn/pixi.js'; import { FilterMemory } from '@drincs/pixi-vn/filters'; /** * 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 * ```ts * 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; /** * The filters applied to this element, if any - kept separate from the real, live `Filter[]` * `.filters` (inherited from the PixiJS options types this memory interface also extends) since a * memory object is serialized data, not construction options. Only filters registered with * {@link filterDecorator}/{@link RegisteredFilters} can be saved - any other `Filter` instance found * on `.filters` is skipped (with a warning) when exporting. */ pixivnFilters?: FilterMemory[]; } /** * 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 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; type ContainerChild = Container & CanvasBaseItem; 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["on"]; readonly onEventsHandlers: OnEventsHandlers; } declare function addListenerHandler(event: symbol | string, element: T, fn: (...args: never[]) => unknown): boolean; /** * Interface for the canvas container memory */ interface ContainerMemory extends ContainerOptions, CanvasBaseItemMemory, ListenerExtensionMemory, AdditionalPositionsExtensionProps { /** * The elements contained in this container */ elements: CanvasBaseItemMemory[]; } export { CanvasBaseItem as a, addListenerHandler as g, analizePositionsExtensionProps as h }; export type { AdditionalPositionsExtensionProps as A, CanvasBaseItemMemory as C, ListenerExtensionMemory as L, OnEventsHandlers as O, CanvasGameState as b, ContainerChild as c, ListenerExtension as d, AdditionalPositionsExtension as e, ContainerMemory as f };