@mediamonks/fast-image-sequence
Version:
The fast-image-sequence-renderer is a powerful package that allows you to display a sequence of images at a high frame rate on your website. Zero dependencies.
63 lines (62 loc) • 2.96 kB
TypeScript
import { FastImageSequence } from './FastImageSequence.js';
import { default as ImageElement } from './ImageElement.js';
export declare const INPUT_SRC = 0;
export declare const INPUT_TAR = 1;
export declare const INPUT_CODE = 2;
export type ImageSourceType = typeof INPUT_SRC | typeof INPUT_TAR | typeof INPUT_CODE;
/**
* @typedef ImageSourceOptions
*
* This type represents the options for the ImageSource class.
*
* @property {((index: number) => string) | undefined} imageURL - A callback function that returns the URL of an image given its index.
* @property {string | undefined} tarURL - The URL of the tar file containing the images for the sequence.
* @property {boolean} useWorker - Whether to use a worker for fetching images.
* @property {number} maxCachedImages - The number of images to cache.
* @property {number} maxConnectionLimit - The maximum number of images to load simultaneously.
* @property {((index: number) => boolean) | undefined} available - A callback function that returns if an image is available given its index.
* @property {((index: number) => Promise<CanvasImageSource>) | undefined} image - A callback function that returns the image element given its index.
* @property {number} timeout - Only start loading an image if the same frame is visible for this time (in milliseconds).
*/
export type ImageSourceOptions = {
imageURL: ((index: number) => string) | undefined;
tarURL: string | undefined;
useWorker: boolean;
maxCachedImages: number;
maxConnectionLimit: number;
available: ((index: number) => boolean) | undefined;
image: ((index: number) => Promise<CanvasImageSource>) | undefined;
timeout: number;
};
export default class ImageSource {
private static defaultOptions;
options: ImageSourceOptions;
index: number;
initialized: boolean;
protected context: FastImageSequence;
constructor(context: FastImageSequence, index: number, options: Partial<ImageSourceOptions>);
initFrames(): void;
get type(): number;
get maxCachedImages(): number;
protected get images(): ImageElement[];
/**
* Set the maximum number of images to cache.
* @param maxCache - The maximum number of images to cache.
* @param onProgress - A callback function that is called with the progress of the loading.
*/
setMaxCachedImages(maxCache: number, onProgress?: (progress: number) => void): Promise<boolean>;
getImageURL(index: number): string | undefined;
checkImageAvailability(): void;
loadResources(): Promise<void>;
process(setLoadingPriority: () => void): void;
getLoadStatus(): {
progress: number;
numLoading: number;
numLoaded: number;
maxLoaded: number;
};
fetchImage(imageElement: ImageElement): Promise<CanvasImageSource>;
destruct(): void;
protected available(image: ImageElement, available?: boolean): boolean;
private releaseImageWithLowestPriority;
}