UNPKG

@pixi/core

Version:
64 lines (63 loc) 2.88 kB
"use strict"; var Texture = require("../textures/Texture.js"), BaseRenderTexture = require("./BaseRenderTexture.js"); class RenderTexture extends Texture.Texture { /** * @param baseRenderTexture - The base texture object that this texture uses. * @param frame - The rectangle frame of the texture to show. */ constructor(baseRenderTexture, frame) { super(baseRenderTexture, frame), this.valid = !0, this.filterFrame = null, this.filterPoolKey = null, this.updateUvs(); } /** * Shortcut to `this.baseTexture.framebuffer`, saves baseTexture cast. * @readonly */ get framebuffer() { return this.baseTexture.framebuffer; } /** * Shortcut to `this.framebuffer.multisample`. * @default PIXI.MSAA_QUALITY.NONE */ get multisample() { return this.framebuffer.multisample; } set multisample(value) { this.framebuffer.multisample = value; } /** * Resizes the RenderTexture. * @param desiredWidth - The desired width to resize to. * @param desiredHeight - The desired height to resize to. * @param resizeBaseTexture - Should the baseTexture.width and height values be resized as well? */ resize(desiredWidth, desiredHeight, resizeBaseTexture = !0) { const resolution = this.baseTexture.resolution, width = Math.round(desiredWidth * resolution) / resolution, height = Math.round(desiredHeight * resolution) / resolution; this.valid = width > 0 && height > 0, this._frame.width = this.orig.width = width, this._frame.height = this.orig.height = height, resizeBaseTexture && this.baseTexture.resize(width, height), this.updateUvs(); } /** * Changes the resolution of baseTexture, but does not change framebuffer size. * @param resolution - The new resolution to apply to RenderTexture */ setResolution(resolution) { const { baseTexture } = this; baseTexture.resolution !== resolution && (baseTexture.setResolution(resolution), this.resize(baseTexture.width, baseTexture.height, !1)); } /** * A short hand way of creating a render texture. * @param options - Options * @param {number} [options.width=100] - The width of the render texture * @param {number} [options.height=100] - The height of the render texture * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.BaseTexture.defaultOptions.scaleMode] - See {@link PIXI.SCALE_MODES} * for possible values * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio of the texture * being generated * @param {PIXI.MSAA_QUALITY} [options.multisample=PIXI.MSAA_QUALITY.NONE] - The number of samples of the frame buffer * @returns The new render texture */ static create(options) { return new RenderTexture(new BaseRenderTexture.BaseRenderTexture(options)); } } exports.RenderTexture = RenderTexture; //# sourceMappingURL=RenderTexture.js.map