⚡ postpone update to next microtask
This commit is contained in:
@@ -12,6 +12,12 @@ export default class Canvas2d extends Node {
|
||||
Object.assign({
|
||||
image: {
|
||||
type: 'Image',
|
||||
},
|
||||
width: {
|
||||
type: 'Number',
|
||||
},
|
||||
height: {
|
||||
type: 'Number',
|
||||
}
|
||||
}, outputDefiniton),
|
||||
options
|
||||
@@ -19,7 +25,7 @@ export default class Canvas2d extends Node {
|
||||
this.__canvas = document.createElement('canvas');
|
||||
}
|
||||
|
||||
async __update() {
|
||||
async _update() {
|
||||
const values = {};
|
||||
for (let name of Object.keys(this.in.variables)) {
|
||||
values[name] = await waitForMedia(this.in[name].value);
|
||||
@@ -28,7 +34,12 @@ export default class Canvas2d extends Node {
|
||||
if (this.__canvas.width > 0 && this.__canvas.height > 0) {
|
||||
ctx.clearRect(0,0,this.__canvas.width, this.__canvas.height);
|
||||
}
|
||||
await this.render(values, this.__canvas, ctx);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +48,9 @@ export default class Canvas2d extends Node {
|
||||
* @param {any} values
|
||||
* @param {HTMLCanvasElement} canvas
|
||||
* @param {CanvasRenderingContext2D} ctx
|
||||
* @returns {Promise<ImageBitmap|null>}
|
||||
*/
|
||||
async render(values, canvas, ctx) {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user