2019-10-27 13:34:44 -05:00
|
|
|
import {Renderer as PIXIRenderer} from '@pixi/core';
|
2019-03-18 20:06:47 -05:00
|
|
|
|
|
|
|
export class Renderer {
|
|
|
|
|
2019-03-25 23:39:07 -05:00
|
|
|
constructor(size = [0, 0], type = 'auto') {
|
2019-10-27 13:34:44 -05:00
|
|
|
this.renderer = new PIXIRenderer(size[0], size[1]);
|
|
|
|
// Need to set size explicitly since v5.
|
|
|
|
this.renderer.view.width = size[0];
|
|
|
|
this.renderer.view.height = size[1];
|
2019-03-18 20:06:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
destroy() {
|
|
|
|
this.renderer.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
get element() {
|
|
|
|
return this.renderer.view;
|
|
|
|
}
|
|
|
|
|
|
|
|
get height() {
|
|
|
|
return this.element.height;
|
|
|
|
}
|
|
|
|
|
2019-03-25 10:14:55 -05:00
|
|
|
render(item, canvas) {
|
|
|
|
const canvasInternal = canvas ? canvas.internal : undefined;
|
|
|
|
this.renderer.render(item.internal, canvasInternal);
|
2019-03-18 20:06:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
get size() {
|
|
|
|
return [this.width, this.height];
|
|
|
|
}
|
|
|
|
|
|
|
|
get width() {
|
|
|
|
return this.element.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|