Class: SVGResource

PIXI.SVGResource

Resource type for SVG elements and graphics.

new PIXI.SVGResource (sourceBase64, options) overrides

Name Type Attributes Default Description
sourceBase64 string

Base64 encoded SVG element or URL for SVG file.

options object <optional>

Options to use

options.scale number <optional>
1

Scale to apply to SVG. Overridden by...

options.width number <optional>

Rasterize SVG this wide. Aspect ratio preserved if height not specified.

options.height number <optional>

Rasterize SVG this high. Aspect ratio preserved if width not specified.

options.autoLoad boolean <optional>
true

Start loading right away.

Extends

Members

PIXI.SVGResource.SVG_SIZE staticreadonly

Regular expression for SVG size.

Default Value:
  • undefined
Example
&lt;svg width="100" height="100"&gt;&lt;/svg&gt;

PIXI.SVGResource.SVG_XML staticreadonly

Regular expression for SVG XML document.

Default Value:
  • undefined
Example
&lt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;!-- image/svg --&gt;&lt;svg

_overrideHeight number readonly

A height override for rasterization on load.

_overrideWidth number readonly

A width override for rasterization on load.

scale number readonly

The source scale to apply when rasterizing on load.

svg string readonly

Base64 encoded SVG element or URL for SVG file.

Methods

PIXI.SVGResource.getSize (svgString) ISize static

Get size from an svg string using a regular expression.

Name Type Attributes Description
svgString string <optional>

a serialized svg element

Returns:
Type Description
ISize
  • image extension

PIXI.SVGResource.test (source, extension) boolean static

Used to auto-detect the type of resource.

Name Type Attributes Description
source unknown

The source object

extension string <optional>

The extension of source, if set

Returns:
Type Description
boolean
  • If the source is a SVG source or data file

dispose () void overrides

Destroys this texture.

Inherited Properties

From class PIXI.BaseImageResource

source HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | SVGElement readonly inherited

The source element.

From class PIXI.Resource

destroyed boolean readonly inherited

If resource has been destroyed.

Default Value:
  • false

height number readonly inherited

The height of the resource.

internal boolean inherited

true if resource is created by BaseTexture useful for doing cleanup with BaseTexture destroy and not cleaning up resources that were created externally.

src string inherited

The url of the resource

valid boolean readonly inherited

Has been validated

width number readonly inherited

The width of the resource.

_height number protected inherited

Internal height of the resource.

_width number protected inherited

Internal width of the resource.

Inherited Methods

From class PIXI.BaseImageResource

Checks if source width/height was changed, resize can cause extra baseTexture update. Triggers one update in any case.

upload (renderer, baseTexture, glTexture, source) boolean inherited

Upload the texture to the GPU.

Name Type Attributes Description
renderer PIXI.Renderer

Upload to the renderer

baseTexture PIXI.BaseTexture

Reference to parent texture

glTexture PIXI.GLTexture
source HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | SVGElement <optional>

(optional)

Returns:
Type Description
boolean
  • true is success

From class PIXI.Resource

bind (baseTexture) void inherited

Bind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

destroy () void inherited

Call when destroying resource, unbind any BaseTexture object before calling this method, as reference counts are maintained internally.

resize (width, height) void inherited

Trigger a resize event

Name Type Description
width number

X dimension

height number

Y dimension

style (_renderer, _baseTexture, _glTexture) boolean inherited

Set the style, optional to override

Name Type Description
_renderer PIXI.Renderer

yeah, renderer!

_baseTexture PIXI.BaseTexture

the texture

_glTexture PIXI.GLTexture

texture instance for this webgl context

Returns:
Type Description
boolean
  • true is success

unbind (baseTexture) void inherited

Unbind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

load () Promise<PIXI.Resource> protected inherited

This can be overridden to start preloading a resource or do any other prepare step.

Returns:
Type Description
Promise<PIXI.Resource> Handle the validate event