UNPKG

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