Class: SVGResource

PIXI.resources.SVGResource

Resource type for SVG elements and graphics.

new PIXI.resources.SVGResource (source, options)

Name Type Description
source string

Base64 encoded SVG element or URL for SVG file.

options object optional

Options to use

Name Type Default Description
scale number 1 optional

Scale to apply to SVG. Overridden by...

width number optional

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

height number optional

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

autoLoad boolean true optional

Start loading right away.

Extends

Members

PIXI.resources.SVGResource.SVG_SIZE RegExp | string staticconstant

RegExp for SVG size.

Example
<svg width="100" height="100"></svg>

_height number protected inherited overrides

Internal height of the resource

_overrideHeight number readonly

A height override for rasterization on load

_overrideWidth number readonly

A width override for rasterization on load

_width number protected inherited overrides

Internal width of the resource

destroyed boolean readonly inherited

If resource has been destroyed

Default Value:
  • false

height number readonly inherited

The height of the resource.

internal boolean protected inherited

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

scale number readonly

The source scale to apply when rasterizing on load

source HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | SVGElement readonly inherited

The source element

svg string readonly

Base64 encoded SVG element or URL for SVG file

valid boolean readonly inherited

Has been validated

width number readonly inherited

The width of the resource.

Methods

PIXI.resources.SVGResource.getSize (svgString)PIXI.ISize static

Get size from an svg string using regexp.

Name Type Description
svgString string

a serialized svg element

Returns:
Type Description
PIXI.ISize image extension

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

Used to auto-detect the type of resource.

Name Type Description
source *

The source object

extension string

The extension of source, if set

bind (baseTexture) inherited

Bind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

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

dispose () protected inherited overrides

Clean up anything, this happens when destroying is ready.

load ()Promise.<void> protected inherited overrides

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

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

resize (width, height) 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) inherited

Unbind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

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 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