deferred drawing
This commit is contained in:
parent
7d6b54825d
commit
c58861bc93
13
canvas.ts
13
canvas.ts
@ -89,6 +89,7 @@ export class Doodler {
|
||||
// }
|
||||
for (const [i, l] of (this.layers || []).entries()) {
|
||||
l(this.ctx, i);
|
||||
this.drawDeferred();
|
||||
}
|
||||
this.drawUI();
|
||||
}
|
||||
@ -227,6 +228,18 @@ export class Doodler {
|
||||
);
|
||||
}
|
||||
|
||||
private deferredDrawings: (() => void)[] = [];
|
||||
|
||||
deferDrawing(cb: () => void) {
|
||||
this.deferredDrawings.push(cb);
|
||||
}
|
||||
|
||||
drawDeferred() {
|
||||
while (this.deferredDrawings.length) {
|
||||
this.deferredDrawings.pop()?.();
|
||||
}
|
||||
}
|
||||
|
||||
setStyle(style?: IStyle) {
|
||||
const ctx = this.ctx;
|
||||
ctx.fillStyle = style?.color || style?.fillColor || "black";
|
||||
|
Loading…
x
Reference in New Issue
Block a user