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
testmethod and a constructor with the arguments(source, options?). Currently, the supported resources for auto-detection include:Name Type Description sourcestring | * 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.
optionsobject optional Pass-through options to use for Resource
Name Type Default Description widthnumber optional BufferResource's width
heightnumber optional BufferResource's height
autoLoadboolean true optional Image, SVG and Video flag to start loading
scalenumber 1 optional SVG source scale
createBitmapboolean true optional Image option to create Bitmap object
crossoriginboolean true optional Image and Video option to set crossOrigin
Returns:
Type Description PIXI.resources.Resource The created resource.