UNPKG

3 kBTypeScriptView Raw
1import type { ICanvas } from '@pixi/settings';
2import type { IRenderer, IRendererOptions } from './IRenderer';
3export interface IRendererOptionsAuto extends IRendererOptions {
4 forceCanvas?: boolean;
5}
6export interface IRendererConstructor<VIEW extends ICanvas = ICanvas> {
7 test(options?: IRendererOptionsAuto): boolean;
8 new (options?: IRendererOptionsAuto): IRenderer<VIEW>;
9}
10/**
11 * This helper function will automatically detect which renderer you should be using.
12 * WebGL is the preferred renderer as it is a lot faster. If WebGL is not supported by
13 * the browser then this function will return a canvas renderer
14 * @memberof PIXI
15 * @function autoDetectRenderer
16 * @param {object} [options] - The optional renderer parameters
17 * @param {number} [options.width=800] - the width of the renderers view
18 * @param {number} [options.height=600] - the height of the renderers view
19 * @param {PIXI.ICanvas} [options.view] - the canvas to use as a view, optional
20 * @param {boolean} [options.useContextAlpha=true] - Pass-through value for canvas' context `alpha` property.
21 * If you want to set transparency, please use `backgroundAlpha`. This option is for cases where the
22 * canvas needs to be opaque, possibly for performance reasons on some older devices.
23 * @param {boolean} [options.autoDensity=false] - Resizes renderer view in CSS pixels to allow for
24 * resolutions other than 1
25 * @param {boolean} [options.antialias=false] - sets antialias
26 * @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, enable this if you
27 * need to call toDataUrl on the webgl context
28 * @param {number|string} [options.backgroundColor=0x000000] - The background color of the rendered area
29 * (shown if not transparent). Also, accepts hex strings or color names (e.g., 'white').
30 * @param {number|string} [options.background] - Alias for `options.backgroundColor`.
31 * @param {number} [options.backgroundAlpha=1] - Value from 0 (fully transparent) to 1 (fully opaque).
32 * @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or
33 * not before the new render pass.
34 * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio of the renderer.
35 * @param {boolean} [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present, this
36 * option only is available when using **pixi.js-legacy** or **@pixi/canvas-renderer** modules, otherwise
37 * it is ignored.
38 * @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance"
39 * for devices with dual graphics card **webgl only**
40 * @param {boolean} [options.hello=false] - Logs renderer type and version.
41 * @returns {PIXI.Renderer|PIXI.CanvasRenderer} Returns WebGL renderer if available, otherwise CanvasRenderer
42 */
43export declare function autoDetectRenderer<VIEW extends ICanvas = ICanvas>(options?: IRendererOptionsAuto): IRenderer<VIEW>;