UNPKG

@drincs/pixi-vn

Version:

Pixi'VN is a npm package that provides various features for creating visual novels.

125 lines (122 loc) 7.2 kB
import { UPDATE_PRIORITY } from 'pixi.js'; import CanvasBase from '../classes/canvas/CanvasBase.mjs'; import CanvasImage from '../classes/canvas/CanvasImage.mjs'; import CanvasSprite from '../classes/canvas/CanvasSprite.mjs'; import { FadeAlphaTickerProps } from '../types/ticker/FadeAlphaTickerProps.mjs'; import { MoveTickerProps } from '../types/ticker/MoveTickerProps.mjs'; import { ZoomTickerProps } from '../types/ticker/ZoomTickerProps.mjs'; import { tagToRemoveAfterType } from '../types/ticker/TagToRemoveAfterType.mjs'; import '../interface/canvas/ICanvasBaseMemory.mjs'; import '../interface/canvas/ICanvasImageMemory.mjs'; import '../interface/canvas/ICanvasSpriteMemory.mjs'; import '../types/EventIdType.mjs'; import '../interface/canvas/ITextureMemory.mjs'; import '../types/CanvasEventNamesType.mjs'; import '../classes/CanvasEvent.mjs'; import '../interface/TickerProgrationType.mjs'; /** * Add a image in the canvas. * Is the same that showImage, but the image is not shown. * If you want to show the image, then you need to use the function CanvasImage.load(). * @param tag is the unique tag of the image. You can use this tag to refer to this image * @param imageUrl is the url of the image. * @returns the container of the image. * @example * ```typescript * let alien = addImage("bunny1", "https://pixijs.com/assets/eggHead.png") * await alien.load() * ``` */ declare function addImage(tag: string, imageUrl: string): CanvasImage; /** * Show a list of images in the canvas, at the same time. * @param canvasImages is a list of images to show. * @returns the list of images. */ declare function loadImage(canvasImages: CanvasImage[] | CanvasImage): Promise<CanvasImage[]>; /** * Add and show a image in the canvas. This function is a combination of {@link addImage} and {@link loadImage}. * @param tag The unique tag of the image. You can use this tag to refer to this image * @param imageUrl The url of the image. * @returns A promise that is resolved when the image is loaded. */ declare function showImage(tag: string, imageUrl: string): Promise<CanvasImage>; /** * Remove a image from the canvas. * @param tag is the unique tag of the image. You can use this tag to refer to this image */ declare function removeCanvasElement(tag: string | string[]): void; /** * 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 tag, then the image is replaced and the first image is removed after the effect is done. * This transition is done with a {@link FadeAlphaTicker} effect. * @param tag The unique tag of the image. You can use this tag to refer to this image * @param image The imageUrl or the canvas element * @param props The properties of the effect * @param priority The priority of the effect * @returns A promise that is resolved when the image is loaded. */ declare function showWithDissolveTransition<T extends CanvasBase<any> | string = string>(tag: string, image: T, props?: Omit<FadeAlphaTickerProps, "type" | tagToRemoveAfterType | "startOnlyIfHaveTexture">, priority?: UPDATE_PRIORITY): Promise<void>; /** * 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 transition is done with a {@link FadeAlphaTicker} effect. * This function is equivalent to {@link removeWithFadeTransition}. * @param tag The unique tag of the image. You can use this tag to refer to this image * @param props The properties of the effect * @param priority The priority of the effect */ declare function removeWithDissolveTransition(tag: string | string[], props?: Omit<FadeAlphaTickerProps, "type" | tagToRemoveAfterType | "startOnlyIfHaveTexture">, priority?: UPDATE_PRIORITY): void; /** * 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 tag, 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 tag The unique tag of the image. You can use this tag to refer to this image * @param image The imageUrl or the canvas element * @param props The properties of the effect * @param priority The priority of the effect * @returns A promise that is resolved when the image is loaded. */ declare function showWithFadeTransition<T extends CanvasBase<any> | string = string>(tag: string, image: T, props?: Omit<FadeAlphaTickerProps, "type" | tagToRemoveAfterType | "startOnlyIfHaveTexture">, priority?: UPDATE_PRIORITY): Promise<void>; /** * 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 transition is done with a {@link FadeAlphaTicker} effect. * This function is equivalent to {@link removeWithDissolveTransition}. * @param tag The unique tag of the image. You can use this tag to refer to this image * @param props The properties of the effect * @param priority The priority of the effect */ declare function removeWithFadeTransition(tag: string | string[], props?: Omit<FadeAlphaTickerProps, "type" | tagToRemoveAfterType | "startOnlyIfHaveTexture">, priority?: UPDATE_PRIORITY): void; type MoveInOutProps = { /** * The direction of the movement. */ direction: "up" | "down" | "left" | "right"; } & Omit<MoveTickerProps, tagToRemoveAfterType | "startOnlyIfHaveTexture" | "destination">; /** * 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. * @param tag The unique tag of the image. You can use this tag to refer to this image * @param image The imageUrl or the canvas element * @param props The properties of the effect * @param priority The priority of the effect * @returns A promise that is resolved when the image is loaded. */ declare function moveIn<T extends CanvasBase<any> | string = string>(tag: string, image: T, props?: MoveInOutProps, priority?: UPDATE_PRIORITY): Promise<void>; /** * 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. * @param tag The unique tag of the image. You can use this tag to refer to this image * @param props The properties of the effect * @param priority The priority of the effect */ declare function moveOut(tag: string, props?: MoveInOutProps, priority?: UPDATE_PRIORITY): void; type ZoomInOutProps = { /** * The direction of the zoom effect. */ direction: "up" | "down" | "left" | "right"; } & Omit<ZoomTickerProps, tagToRemoveAfterType | "startOnlyIfHaveTexture" | "type">; declare function zoomIn<T extends CanvasSprite | string = string>(tag: string, image: T, props?: ZoomInOutProps, priority?: UPDATE_PRIORITY): Promise<void>; declare function zoomOut(tag: string, props?: ZoomInOutProps, priority?: UPDATE_PRIORITY): void; export { addImage, loadImage, moveIn, moveOut, removeCanvasElement, removeWithDissolveTransition, removeWithFadeTransition, showImage, showWithDissolveTransition, showWithFadeTransition, zoomIn, zoomOut };