destroy methods

This commit is contained in:
2019-01-25 22:59:42 +01:00
parent 43736b0415
commit 23f59be7da
9 changed files with 71 additions and 19 deletions

View File

@@ -25,6 +25,11 @@ export default class Canvas2d extends Node {
this.__canvas = document.createElement('canvas');
}
destroy() {
this.__canvas = null;
super.destroy();
}
async _update() {
const values = {};
for (let name of Object.keys(this.in.variables)) {
@@ -37,8 +42,12 @@ export default class Canvas2d extends Node {
const result = await this.render(values, this.__canvas, ctx);
if (result instanceof ImageBitmap) {
this.__out.image.value = result;
this.out.width.value = this.out.image.value.width;
this.out.height.value = this.out.image.value.height;
if (this.out.width.value !== this.out.image.value.width) {
this.out.width.value = this.out.image.value.width;
}
if (this.out.height.value !== this.out.image.value.height) {
this.out.height.value = this.out.image.value.height;
}
}
}

View File

@@ -65,7 +65,6 @@ export default class Resize extends Canvas2d {
ctx.textAlign = textAlign;
const x = textAlign === 'center' ? canvas.width /2 :
textAlign === 'left' ? 0 : canvas.width;
console.log(text.split('\\n'));
text.split('\\n').forEach((line, index) => {
ctx.fillText(line, x, fontSize * (1 + index));
});