UNPKG

@drincs/pixi-vn

Version:

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

134 lines (125 loc) 3.2 kB
import { UPDATE_PRIORITY } from 'pixi.js'; /** * is a string that represents a ticker id. * It is used to {@link canvas.tickers} to get the ticker class. */ type TickerIdType = string; interface TickerArgs { } interface Ticker<TArgs extends TickerArgs> { /** * Arguments to pass to the ticker */ args: TArgs; /** * Duration in seconds to run the ticker */ duration?: number; /** * Priority of the ticker */ priority?: UPDATE_PRIORITY; /** * Get the id of the ticker. This variable is used in the system to get the ticker by id, {@link RegisteredTickers.getInstance} */ id: TickerIdType; /** * 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> | 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. * @param id The id of the ticker. */ start: (id: string) => 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; } /** * TickerHistory is a class that contains the name of a class and the arguments that were used to create it. */ interface TickerInfo<TArgs extends TickerArgs> { /** * If this ticker was created by steps */ createdByTicketSteps?: { canvasElementAlias: string; id: string; }; ticker: Ticker<TArgs>; } interface TickerHistory<TArgs extends TickerArgs> { id: TickerIdType; args: TArgs; /** * The aliases of the canvas elements that are connected to this ticker */ canvasElementAliases: string[]; priority?: UPDATE_PRIORITY; duration?: number; paused?: boolean; } type PauseType = { /** * The type of the value */ type: "pause"; /** * Duration in seconds */ duration: number; }; type RepeatType = "repeat"; interface TickersStep<TArgs extends TickerArgs> { /** * 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; } /** * The steps of the tickers */ interface TickersSequence { /** * The step number */ currentStepNumber: number; /** * The steps of the tickers */ steps: (TickersStep<any> | RepeatType | PauseType)[]; } export type { PauseType as P, RepeatType as R, Ticker as T, TickerArgs as a, TickerHistory as b, TickerInfo as c, TickersSequence as d, TickerIdType as e };