1 | import { BaseImageResource } from './BaseImageResource';
|
2 | import type { ISize } from '@pixi/math';
|
3 | export interface ISVGResourceOptions {
|
4 | source?: string;
|
5 | scale?: number;
|
6 | width?: number;
|
7 | height?: number;
|
8 | autoLoad?: boolean;
|
9 | crossorigin?: boolean | string;
|
10 | }
|
11 | /**
|
12 | * Resource type for SVG elements and graphics.
|
13 | * @memberof PIXI
|
14 | */
|
15 | export declare class SVGResource extends BaseImageResource {
|
16 | /** Base64 encoded SVG element or URL for SVG file. */
|
17 | readonly svg: string;
|
18 | /** The source scale to apply when rasterizing on load. */
|
19 | readonly scale: number;
|
20 | /** A width override for rasterization on load. */
|
21 | readonly _overrideWidth: number;
|
22 | /** A height override for rasterization on load. */
|
23 | readonly _overrideHeight: number;
|
24 | /** Call when completely loaded. */
|
25 | private _resolve;
|
26 | /** Promise when loading */
|
27 | private _load;
|
28 | /** Cross origin value to use */
|
29 | private _crossorigin?;
|
30 | /**
|
31 | * @param sourceBase64 - Base64 encoded SVG element or URL for SVG file.
|
32 | * @param {object} [options] - Options to use
|
33 | * @param {number} [options.scale=1] - Scale to apply to SVG. Overridden by...
|
34 | * @param {number} [options.width] - Rasterize SVG this wide. Aspect ratio preserved if height not specified.
|
35 | * @param {number} [options.height] - Rasterize SVG this high. Aspect ratio preserved if width not specified.
|
36 | * @param {boolean} [options.autoLoad=true] - Start loading right away.
|
37 | */
|
38 | constructor(sourceBase64: string, options?: ISVGResourceOptions);
|
39 | load(): Promise<SVGResource>;
|
40 | /** Loads an SVG image from `imageUrl` or `data URL`. */
|
41 | private _loadSvg;
|
42 | /**
|
43 | * Get size from an svg string using a regular expression.
|
44 | * @param svgString - a serialized svg element
|
45 | * @returns - image extension
|
46 | */
|
47 | static getSize(svgString?: string): ISize;
|
48 | /** Destroys this texture. */
|
49 | dispose(): void;
|
50 | /**
|
51 | * Used to auto-detect the type of resource.
|
52 | * @param {*} source - The source object
|
53 | * string} extension - The extension of source, if set
{ |
54 | * boolean} - If the source is a SVG source or data file
{ |
55 | */
|
56 | static test(source: unknown, extension?: string): boolean;
|
57 | /**
|
58 | * Regular expression for SVG XML document.
|
59 | * @example <?xml version="1.0" encoding="utf-8" ?><!-- image/svg --><svg
|
60 | * @readonly
|
61 | */
|
62 | static SVG_XML: RegExp;
|
63 | /**
|
64 | * Regular expression for SVG size.
|
65 | * @example <svg width="100" height="100"></svg>
|
66 | * @readonly
|
67 | */
|
68 | static SVG_SIZE: RegExp;
|
69 | }
|