PIXI.SVGResource

class SVGResource extends PIXI.BaseImageResource

Resource type for SVG elements and graphics.

Constructor


new PIXI.SVGResource(sourceBase64: string, options: object) → {}
Parameters:
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.

Summary


Properties from SVGResource

static SVG_SIZE = undefined
static SVG_XML = undefined
number
_overrideHeight

A height override for rasterization on load.

number
_overrideWidth

A width override for rasterization on load.

number
scale

The source scale to apply when rasterizing on load.

string
svg

Base64 encoded SVG element or URL for SVG file.

Methods from SVGResource

Properties inherited from BaseImageResource

HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | SVGElement
source

Properties inherited from Resource

boolean
destroyed = false
number
height
boolean
internal
string
src

The url of the resource

boolean
valid
number
width
number
protected _height

Internal height of the resource.

number
protected _width

Internal width of the resource.

Methods inherited from BaseImageResource

void
update()
boolean
upload(renderer: PIXI.Renderer, baseTexture: PIXI.BaseTexture, glTexture: PIXI.GLTexture, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | SVGElement)

Public Properties


SVG_SIZE SVGResource.ts:219
static SVG_SIZE = undefined

Regular expression for SVG size.

&lt;svg width="100" height="100"&gt;&lt;/svg&gt;
SVG_XML SVGResource.ts:212
static SVG_XML = undefined

Regular expression for SVG XML document.

&lt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;!-- image/svg --&gt;&lt;svg
_overrideHeight SVGResource.ts:31
_overrideHeight: number

A height override for rasterization on load.

_overrideWidth SVGResource.ts:28
_overrideWidth: number

A width override for rasterization on load.

scale SVGResource.ts:25
scale: number

The source scale to apply when rasterizing on load.

svg SVGResource.ts:22
svg: string

Base64 encoded SVG element or URL for SVG file.

Public Methods


getSize SVGResource.ts:169
static getSize(svgString: string) → {ISize}

Get size from an svg string using a regular expression.

Parameters:
Name Type Attributes Description
svgString string

<optional>

a serialized svg element

Returns:
Type Description
ISize
  • image extension
test SVGResource.ts:196
static test(source: unknown, extension: string) → {boolean}

Used to auto-detect the type of resource.

Parameters:
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 SVGResource.ts:188
dispose() → {void}

Destroys this texture.

Returns:
Type Description
void

Powered by webdoc!