40 lines
1.7 KiB
JavaScript
40 lines
1.7 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$canvas$texture$CanvasTextureSystem = 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");
|
|
var canvasUtils = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$canvas$utils$canvasUtils");
|
|
"use strict";
|
|
class CanvasTextureSystem {
|
|
constructor(renderer) {
|
|
}
|
|
init() {
|
|
}
|
|
initSource(_source) {
|
|
}
|
|
generateCanvas(texture) {
|
|
const canvas = adapter.DOMAdapter.get().createCanvas(), context = canvas.getContext("2d"), source = canvasUtils.canvasUtils.getCanvasSource(texture);
|
|
if (!source) {
|
|
return canvas;
|
|
}
|
|
var frame = texture.frame;
|
|
const resolution = texture.source._resolution ?? texture.source.resolution ?? 1;
|
|
texture = frame.x * resolution;
|
|
const sy = frame.y * resolution, sw = frame.width * resolution;
|
|
frame = frame.height * resolution;
|
|
canvas.width = Math.ceil(sw);
|
|
canvas.height = Math.ceil(frame);
|
|
context.drawImage(source, texture, sy, sw, frame, 0, 0, sw, frame);
|
|
return canvas;
|
|
}
|
|
getPixels(texture) {
|
|
texture = this.generateCanvas(texture);
|
|
return {pixels:texture.getContext("2d", {willReadFrequently:!0}).getImageData(0, 0, texture.width, texture.height).data, width:texture.width, height:texture.height};
|
|
}
|
|
destroy() {
|
|
}
|
|
}
|
|
CanvasTextureSystem.extension = {type:[global.ExtensionType.CanvasSystem], name:"texture"};
|
|
exports.CanvasTextureSystem = CanvasTextureSystem;
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$canvas$texture$CanvasTextureSystem.js.map
|