Files
il/resources/public/js/cljs-runtime/module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$sources$CanvasSource.js
2026-07-01 22:38:29 -06:00

39 lines
2.1 KiB
JavaScript

shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$sources$CanvasSource = function(global, require, module, exports) {
var adapter = require("module$node_modules$pixi_DOT_js$lib$environment$adapter");
global = require("module$node_modules$pixi_DOT_js$lib$extensions$Extensions");
require = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$sources$TextureSource");
"use strict";
class CanvasSource extends require.TextureSource {
constructor(options) {
options.resource || (options.resource = adapter.DOMAdapter.get().createCanvas());
options.width || (options.width = options.resource.width, options.autoDensity || (options.width /= options.resolution));
options.height || (options.height = options.resource.height, options.autoDensity || (options.height /= options.resolution));
super(options);
this.uploadMethodId = "image";
this.autoDensity = options.autoDensity;
this.resizeCanvas();
this.transparent = !!options.transparent;
}
resizeCanvas() {
this.autoDensity && "style" in this.resource && (this.resource.style.width = `${this.width}px`, this.resource.style.height = `${this.height}px`);
if (this.resource.width !== this.pixelWidth || this.resource.height !== this.pixelHeight) {
this.resource.width = this.pixelWidth, this.resource.height = this.pixelHeight;
}
}
resize(width = this.width, height = this.height, resolution = this._resolution) {
(width = super.resize(width, height, resolution)) && this.resizeCanvas();
return width;
}
static test(resource) {
return globalThis.HTMLCanvasElement && resource instanceof HTMLCanvasElement || globalThis.OffscreenCanvas && resource instanceof OffscreenCanvas;
}
get context2D() {
return this._context2D || (this._context2D = this.resource.getContext("2d"));
}
}
CanvasSource.extension = global.ExtensionType.TextureSource;
exports.CanvasSource = CanvasSource;
};
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$sources$CanvasSource.js.map