Initial
This commit is contained in:
66
resources/app/node_modules/@pixi/utils/lib/media/CanvasRenderTarget.mjs
generated
vendored
Normal file
66
resources/app/node_modules/@pixi/utils/lib/media/CanvasRenderTarget.mjs
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import { settings } from "@pixi/settings";
|
||||
class CanvasRenderTarget {
|
||||
/**
|
||||
* @param width - the width for the newly created canvas
|
||||
* @param height - the height for the newly created canvas
|
||||
* @param {number} [resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio of the canvas
|
||||
*/
|
||||
constructor(width, height, resolution) {
|
||||
this._canvas = settings.ADAPTER.createCanvas(), this._context = this._canvas.getContext("2d"), this.resolution = resolution || settings.RESOLUTION, this.resize(width, height);
|
||||
}
|
||||
/**
|
||||
* Clears the canvas that was created by the CanvasRenderTarget class.
|
||||
* @private
|
||||
*/
|
||||
clear() {
|
||||
this._checkDestroyed(), this._context.setTransform(1, 0, 0, 1, 0, 0), this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);
|
||||
}
|
||||
/**
|
||||
* Resizes the canvas to the specified width and height.
|
||||
* @param desiredWidth - the desired width of the canvas
|
||||
* @param desiredHeight - the desired height of the canvas
|
||||
*/
|
||||
resize(desiredWidth, desiredHeight) {
|
||||
this._checkDestroyed(), this._canvas.width = Math.round(desiredWidth * this.resolution), this._canvas.height = Math.round(desiredHeight * this.resolution);
|
||||
}
|
||||
/** Destroys this canvas. */
|
||||
destroy() {
|
||||
this._context = null, this._canvas = null;
|
||||
}
|
||||
/**
|
||||
* The width of the canvas buffer in pixels.
|
||||
* @member {number}
|
||||
*/
|
||||
get width() {
|
||||
return this._checkDestroyed(), this._canvas.width;
|
||||
}
|
||||
set width(val) {
|
||||
this._checkDestroyed(), this._canvas.width = Math.round(val);
|
||||
}
|
||||
/**
|
||||
* The height of the canvas buffer in pixels.
|
||||
* @member {number}
|
||||
*/
|
||||
get height() {
|
||||
return this._checkDestroyed(), this._canvas.height;
|
||||
}
|
||||
set height(val) {
|
||||
this._checkDestroyed(), this._canvas.height = Math.round(val);
|
||||
}
|
||||
/** The Canvas object that belongs to this CanvasRenderTarget. */
|
||||
get canvas() {
|
||||
return this._checkDestroyed(), this._canvas;
|
||||
}
|
||||
/** A CanvasRenderingContext2D object representing a two-dimensional rendering context. */
|
||||
get context() {
|
||||
return this._checkDestroyed(), this._context;
|
||||
}
|
||||
_checkDestroyed() {
|
||||
if (this._canvas === null)
|
||||
throw new TypeError("The CanvasRenderTarget has already been destroyed");
|
||||
}
|
||||
}
|
||||
export {
|
||||
CanvasRenderTarget
|
||||
};
|
||||
//# sourceMappingURL=CanvasRenderTarget.mjs.map
|
||||
Reference in New Issue
Block a user