PIXI.autoDetectRenderer
autoDetectRenderer(options: object) → {PIXI.Renderer | PIXI.CanvasRenderer}
This helper function will automatically detect which renderer you should be using. WebGL is the preferred renderer as it is a lot faster. If WebGL is not supported by the browser then this function will return a canvas renderer
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options | object |
<optional> |
The optional renderer parameters |
|
options.width | number |
<optional> |
800 |
the width of the renderers view |
options.height | number |
<optional> |
600 |
the height of the renderers view |
options.view | HTMLCanvasElement |
<optional> |
the canvas to use as a view, optional |
|
options.useContextAlpha | boolean |
<optional> |
true |
Pass-through value for canvas' context |
options.autoDensity | boolean |
<optional> |
false |
Resizes renderer view in CSS pixels to allow for resolutions other than 1 |
options.antialias | boolean |
<optional> |
false |
sets antialias |
options.preserveDrawingBuffer | boolean |
<optional> |
false |
enables drawing buffer preservation, enable this if you need to call toDataUrl on the webgl context |
options.backgroundColor | number |
<optional> |
0x000000 |
The background color of the rendered area (shown if not transparent). |
options.backgroundAlpha | number |
<optional> |
1 |
Value from 0 (fully transparent) to 1 (fully opaque). |
options.clearBeforeRender | boolean |
<optional> |
true |
This sets if the renderer will clear the canvas or not before the new render pass. |
options.resolution | number |
<optional> |
PIXI.settings.RESOLUTION |
The resolution / device pixel ratio of the renderer. |
options.forceCanvas | boolean |
<optional> |
false |
prevents selection of WebGL renderer, even if such is present, this option only is available when using pixi.js-legacy or @pixi/canvas-renderer modules, otherwise it is ignored. |
options.powerPreference | string |
<optional> |
Parameter passed to webgl context, set to "high-performance" for devices with dual graphics card webgl only |
Type | Description |
---|---|
PIXI.Renderer | PIXI.CanvasRenderer |
Returns WebGL renderer if available, otherwise CanvasRenderer |