UNPKG

3.87 kBTypeScriptView Raw
1import { Color } from '@pixi/color';
2import { MSAA_QUALITY } from '@pixi/constants';
3import { Framebuffer } from '../framebuffer/Framebuffer';
4import { BaseTexture } from '../textures/BaseTexture';
5import type { ColorSource } from '@pixi/color';
6import type { MaskData } from '../mask/MaskData';
7import type { IBaseTextureOptions } from '../textures/BaseTexture';
8export interface BaseRenderTexture extends GlobalMixins.BaseRenderTexture, BaseTexture {
9}
10/**
11 * A BaseRenderTexture is a special texture that allows any PixiJS display object to be rendered to it.
12 *
13 * __Hint__: All DisplayObjects (i.e. Sprites) that render to a BaseRenderTexture should be preloaded
14 * otherwise black rectangles will be drawn instead.
15 *
16 * A BaseRenderTexture takes a snapshot of any Display Object given to its render method. The position
17 * and rotation of the given Display Objects is ignored. For example:
18 * @example
19 * import { autoDetectRenderer, BaseRenderTexture, RenderTexture, Sprite } from 'pixi.js';
20 *
21 * const renderer = autoDetectRenderer();
22 * const baseRenderTexture = new BaseRenderTexture({ width: 800, height: 600 });
23 * const renderTexture = new RenderTexture(baseRenderTexture);
24 * const sprite = Sprite.from('spinObj_01.png');
25 *
26 * sprite.position.x = 800 / 2;
27 * sprite.position.y = 600 / 2;
28 * sprite.anchor.x = 0.5;
29 * sprite.anchor.y = 0.5;
30 *
31 * renderer.render(sprite, { renderTexture });
32 *
33 * // The Sprite in this case will be rendered using its local transform.
34 * // To render this sprite at 0,0 you can clear the transform
35 * sprite.setTransform();
36 *
37 * const baseRenderTexture = new BaseRenderTexture({ width: 100, height: 100 });
38 * const renderTexture = new RenderTexture(baseRenderTexture);
39 *
40 * renderer.render(sprite, { renderTexture }); // Renders to center of RenderTexture
41 * @memberof PIXI
42 */
43export declare class BaseRenderTexture extends BaseTexture {
44 _clear: Color;
45 /**
46 * The framebuffer of this base texture.
47 * @readonly
48 */
49 framebuffer: Framebuffer;
50 /** The data structure for the stencil masks. */
51 maskStack: Array<MaskData>;
52 /** The data structure for the filters. */
53 filterStack: Array<any>;
54 /**
55 * @param options
56 * @param {number} [options.width=100] - The width of the base render texture.
57 * @param {number} [options.height=100] - The height of the base render texture.
58 * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.BaseTexture.defaultOptions.scaleMode] - See {@link PIXI.SCALE_MODES}
59 * for possible values.
60 * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio
61 * of the texture being generated.
62 * @param {PIXI.MSAA_QUALITY} [options.multisample=PIXI.MSAA_QUALITY.NONE] - The number of samples of the frame buffer.
63 */
64 constructor(options?: IBaseTextureOptions);
65 /** Color when clearning the texture. */
66 set clearColor(value: ColorSource);
67 get clearColor(): ColorSource;
68 /**
69 * Color object when clearning the texture.
70 * @readonly
71 * @since 7.2.0
72 */
73 get clear(): Color;
74 /**
75 * Shortcut to `this.framebuffer.multisample`.
76 * @default PIXI.MSAA_QUALITY.NONE
77 */
78 get multisample(): MSAA_QUALITY;
79 set multisample(value: MSAA_QUALITY);
80 /**
81 * Resizes the BaseRenderTexture.
82 * @param desiredWidth - The desired width to resize to.
83 * @param desiredHeight - The desired height to resize to.
84 */
85 resize(desiredWidth: number, desiredHeight: number): void;
86 /**
87 * Frees the texture and framebuffer from WebGL memory without destroying this texture object.
88 * This means you can still use the texture later which will upload it to GPU
89 * memory again.
90 * @fires PIXI.BaseTexture#dispose
91 */
92 dispose(): void;
93 /** Destroys this texture. */
94 destroy(): void;
95}