Collection of base resource types supported by PixiJS. Resources are used by PIXI.BaseTexture to handle different media types such as images, video, SVG graphics, etc. In most use-cases, you should not instantiate the resources directly. The easy thing is to use PIXI.BaseTexture.from.
Example
const baseTexture = PIXI.BaseTexture.from('path/to/image.jpg');
Classes
- ArrayResource
- BaseImageResource
- BufferResource
- CanvasResource
- CubeResource
- ImageResource
- Resource
- SVGResource
- VideoResource
Members
-
Collection of installed resource types, class must extend PIXI.resources.Resource.
Example
class CustomResource extends PIXI.resources.Resource { // MUST have source, options constructor signature // for auto-detected resources to be created. constructor(source, options) { super(); } upload(renderer, baseTexture, glTexture) { // upload with GL } // used to auto-detect resource static test(source, extension) { return extension === 'xyz'|| source instanceof SomeClass; } } // Install the new resource type PIXI.resources.INSTALLED.push(CustomResource);
Methods
-
PIXI.resources.autoDetectResource (source, options)PIXI.resources.Resource static
-
Create a resource element from a single source element. This auto-detects which type of resource to create. All resources that are auto-detectable must have a static
test
method and a constructor with the arguments(source, options?)
. Currently, the supported resources for auto-detection include:Name Type Description source
string | * Resource source, this can be the URL to the resource, a typed-array (for BufferResource), HTMLVideoElement, SVG data-uri or any other resource that can be auto-detected. If not resource is detected, it's assumed to be an ImageResource.
options
object optional Pass-through options to use for Resource
Name Type Default Description width
number optional BufferResource's width
height
number optional BufferResource's height
autoLoad
boolean true optional Image, SVG and Video flag to start loading
scale
number 1 optional SVG source scale
createBitmap
boolean true optional Image option to create Bitmap object
crossorigin
boolean true optional Image and Video option to set crossOrigin
Returns:
Type Description PIXI.resources.Resource The created resource.