UNPKG

2.85 kBTypeScriptView Raw
1import { Rectangle } from '@pixi/math';
2import type { ExtensionMetadata } from '@pixi/extensions';
3import type { ICanvas } from '@pixi/settings';
4import type { IRenderer } from '../IRenderer';
5import type { ISystem } from '../system/ISystem';
6/**
7 * Options for the view system.
8 * @memberof PIXI
9 */
10export interface ViewSystemOptions {
11 /**
12 * The canvas to use as the view. If omitted, a new canvas will be created.
13 * @memberof PIXI.IRendererOptions
14 */
15 view?: ICanvas;
16 /**
17 * The width of the renderer's view.
18 * @memberof PIXI.IRendererOptions
19 */
20 width?: number;
21 /**
22 * The height of the renderer's view.
23 * @memberof PIXI.IRendererOptions
24 */
25 height?: number;
26 /**
27 * The resolution / device pixel ratio of the renderer.
28 * @memberof PIXI.IRendererOptions
29 */
30 resolution?: number;
31 /**
32 * Whether the CSS dimensions of the renderer's view should be resized automatically.
33 * @memberof PIXI.IRendererOptions
34 */
35 autoDensity?: boolean;
36}
37/**
38 * The view system manages the main canvas that is attached to the DOM.
39 * This main role is to deal with how the holding the view reference and dealing with how it is resized.
40 * @memberof PIXI
41 */
42export declare class ViewSystem implements ISystem<ViewSystemOptions, boolean> {
43 /** @ignore */
44 static defaultOptions: ViewSystemOptions;
45 /** @ignore */
46 static extension: ExtensionMetadata;
47 private renderer;
48 /**
49 * The resolution / device pixel ratio of the renderer.
50 * @member {number}
51 * @default PIXI.settings.RESOLUTION
52 */
53 resolution: number;
54 /**
55 * Measurements of the screen. (0, 0, screenWidth, screenHeight).
56 *
57 * Its safe to use as filterArea or hitArea for the whole stage.
58 * @member {PIXI.Rectangle}
59 */
60 screen: Rectangle;
61 /**
62 * The canvas element that everything is drawn to.
63 * @member {PIXI.ICanvas}
64 */
65 element: ICanvas;
66 /**
67 * Whether CSS dimensions of canvas view should be resized to screen dimensions automatically.
68 * @member {boolean}
69 */
70 autoDensity: boolean;
71 constructor(renderer: IRenderer);
72 /**
73 * initiates the view system
74 * @param {PIXI.ViewOptions} options - the options for the view
75 */
76 init(options: ViewSystemOptions): void;
77 /**
78 * Resizes the screen and canvas to the specified dimensions.
79 * @param desiredScreenWidth - The new width of the screen.
80 * @param desiredScreenHeight - The new height of the screen.
81 */
82 resizeView(desiredScreenWidth: number, desiredScreenHeight: number): void;
83 /**
84 * Destroys this System and optionally removes the canvas from the dom.
85 * @param {boolean} [removeView=false] - Whether to remove the canvas from the DOM.
86 */
87 destroy(removeView: boolean): void;
88}