46 lines
803 B
JavaScript
46 lines
803 B
JavaScript
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined;
|
|
|
|
export class Renderer {
|
|
|
|
constructor(size, type = 'auto') {
|
|
switch (type) {
|
|
case 'auto':
|
|
this.renderer = PIXI.autoDetectRenderer(size[0], size[1]);
|
|
break;
|
|
case 'canvas':
|
|
this.renderer = new PIXI.CanvasRenderer(size[0], size[1]);
|
|
break;
|
|
case 'auto':
|
|
this.renderer = new PIXI.Renderer(size[0], size[1]);
|
|
break;
|
|
}
|
|
}
|
|
|
|
destroy() {
|
|
this.renderer.destroy();
|
|
}
|
|
|
|
get element() {
|
|
return this.renderer.view;
|
|
}
|
|
|
|
get height() {
|
|
return this.element.height;
|
|
}
|
|
|
|
render(item) {
|
|
this.renderer.render(item.internal);
|
|
}
|
|
|
|
get size() {
|
|
return [this.width, this.height];
|
|
}
|
|
|
|
get width() {
|
|
return this.element.width;
|
|
}
|
|
|
|
|
|
|
|
}
|