1 | import type { ISize } from '@pixi/math';
|
2 | import type { ICubeResourceOptions } from './CubeResource';
|
3 | import type { IImageResourceOptions } from './ImageResource';
|
4 | import type { Resource } from './Resource';
|
5 | import type { ISVGResourceOptions } from './SVGResource';
|
6 | import type { IVideoResourceOptions } from './VideoResource';
|
7 | export declare type IResourcePluginOptions = {
|
8 | [key: string]: any;
|
9 | };
|
10 | export declare type IAutoDetectOptions = ISize | ICubeResourceOptions | IImageResourceOptions | ISVGResourceOptions | IVideoResourceOptions | IResourcePluginOptions;
|
11 | /**
|
12 | * Shape of supported resource plugins
|
13 | * @memberof PIXI
|
14 | */
|
15 | export interface IResourcePlugin<R, RO> {
|
16 | test(source: unknown, extension: string): boolean;
|
17 | new (source: any, options?: RO): R;
|
18 | }
|
19 | /**
|
20 | * Collection of installed resource types, class must extend {@link PIXI.Resource}.
|
21 | * @example
|
22 | * class CustomResource extends PIXI.Resource {
|
23 | * // MUST have source, options constructor signature
|
24 | * // for auto-detected resources to be created.
|
25 | * constructor(source, options) {
|
26 | * super();
|
27 | * }
|
28 | * upload(renderer, baseTexture, glTexture) {
|
29 | * // Upload with GL
|
30 | * return true;
|
31 | * }
|
32 | * // Used to auto-detect resource
|
33 | * static test(source, extension) {
|
34 | * return extension === 'xyz' || source instanceof SomeClass;
|
35 | * }
|
36 | * }
|
37 | * // Install the new resource type
|
38 | * PIXI.INSTALLED.push(CustomResource);
|
39 | * @memberof PIXI
|
40 | * @type {Array<PIXI.IResourcePlugin>}
|
41 | * @static
|
42 | * @readonly
|
43 | */
|
44 | export declare const INSTALLED: Array<IResourcePlugin<any, any>>;
|
45 | /**
|
46 | * Create a resource element from a single source element. This
|
47 | * auto-detects which type of resource to create. All resources that
|
48 | * are auto-detectable must have a static `test` method and a constructor
|
49 | * with the arguments `(source, options?)`. Currently, the supported
|
50 | * resources for auto-detection include:
|
51 | * - {@link PIXI.ImageResource}
|
52 | * - {@link PIXI.CanvasResource}
|
53 | * - {@link PIXI.VideoResource}
|
54 | * - {@link PIXI.SVGResource}
|
55 | * - {@link PIXI.BufferResource}
|
56 | * @static
|
57 | * @memberof PIXI
|
58 | * @function autoDetectResource
|
59 | * @param {string|*} source - Resource source, this can be the URL to the resource,
|
60 | * a typed-array (for BufferResource), HTMLVideoElement, SVG data-uri
|
61 | * or any other resource that can be auto-detected. If not resource is
|
62 | * detected, it's assumed to be an ImageResource.
|
63 | * @param {object} [options] - Pass-through options to use for Resource
|
64 | * @param {number} [options.width] - Width of BufferResource or SVG rasterization
|
65 | * @param {number} [options.height] - Height of BufferResource or SVG rasterization
|
66 | * @param {boolean} [options.autoLoad=true] - Image, SVG and Video flag to start loading
|
67 | * @param {number} [options.scale=1] - SVG source scale. Overridden by width, height
|
68 | * @param {boolean} [options.createBitmap=PIXI.settings.CREATE_IMAGE_BITMAP] - Image option to create Bitmap object
|
69 | * @param {boolean} [options.crossorigin=true] - Image and Video option to set crossOrigin
|
70 | * @param {boolean} [options.autoPlay=true] - Video option to start playing video immediately
|
71 | * @param {number} [options.updateFPS=0] - Video option to update how many times a second the
|
72 | * texture should be updated from the video. Leave at 0 to update at every render
|
73 | * @returns {PIXI.Resource} The created resource.
|
74 | */
|
75 | export declare function autoDetectResource<R extends Resource, RO>(source: unknown, options?: RO): R;
|