avocado-old/packages/graphics/renderer.js
2020-06-15 17:26:20 -05:00

40 lines
751 B
JavaScript

import {Renderer as PIXIRenderer} from '@pixi/core';
export class Renderer {
constructor(size = [0, 0], type = 'auto') {
this.renderer = new PIXIRenderer({width: size[0], height: size[1]});
// Need to set size explicitly since v5.
this.renderer.view.width = size[0];
this.renderer.view.height = size[1];
}
destroy() {
this.renderer.destroy();
}
get element() {
return this.renderer.view;
}
get height() {
return this.element.height;
}
render(item, canvas) {
const canvasInternal = canvas ? canvas.internal : undefined;
this.renderer.render(item.internal, canvasInternal);
}
get size() {
return [this.width, this.height];
}
get width() {
return this.element.width;
}
}