introduce tags, structs, and reticles
this was meant to be split into smaller changes, but I realised I edited my existing revision too late.
This commit is contained in:
parent
8356b6c750
commit
5b7d9586ea
26 changed files with 1113 additions and 351 deletions
|
@ -21,32 +21,35 @@ export class BrushPreview extends HTMLElement {
|
|||
this.pixmap = new Pixmap(this.canvas.width, this.canvas.height);
|
||||
}
|
||||
|
||||
#renderBrushInner(haku) {
|
||||
haku.resetVm();
|
||||
async #renderBrushInner(haku) {
|
||||
this.pixmap.clear();
|
||||
let evalResult = await haku.evalBrush({
|
||||
runDotter: async () => {
|
||||
return {
|
||||
fromX: this.canvas.width / 2,
|
||||
fromY: this.canvas.width / 2,
|
||||
toX: this.canvas.width / 2,
|
||||
toY: this.canvas.width / 2,
|
||||
num: 0,
|
||||
};
|
||||
},
|
||||
|
||||
let evalResult = haku.evalBrush();
|
||||
runScribble: async (renderToPixmap) => {
|
||||
return renderToPixmap(this.pixmap, 0, 0);
|
||||
},
|
||||
});
|
||||
if (evalResult.status != "ok") {
|
||||
return { status: "error", phase: "eval", result: evalResult };
|
||||
}
|
||||
|
||||
this.pixmap.clear();
|
||||
let renderResult = haku.renderValue(
|
||||
this.pixmap,
|
||||
this.canvas.width / 2,
|
||||
this.canvas.height / 2,
|
||||
);
|
||||
if (renderResult.status != "ok") {
|
||||
return { status: "error", phase: "render", result: renderResult };
|
||||
}
|
||||
|
||||
this.ctx.putImageData(this.pixmap.getImageData(), 0, 0);
|
||||
|
||||
return { status: "ok" };
|
||||
}
|
||||
|
||||
renderBrush(haku) {
|
||||
async renderBrush(haku) {
|
||||
this.unsetErrorFlag();
|
||||
let result = this.#renderBrushInner(haku);
|
||||
let result = await this.#renderBrushInner(haku);
|
||||
if (result.status == "error") {
|
||||
this.setErrorFlag();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue