test load picture on canvas

This commit is contained in:
2022-12-06 17:41:32 +01:00
parent 83c14b8001
commit 6bd75ba840
5 changed files with 75 additions and 11 deletions

View File

@ -38,8 +38,10 @@
getDraw1d: "draw1d",
getDraw2d: "draw2d",
getDraw2dLast: "draw2dLast",
getDraw2dPicture: "draw2dpicture",
boardWidth: "boardWidth",
boardHeight: "boardHeight",
picture: "picture",
}),
...mapWritableState(globalStore, {
lastBoard: "lastBoard",
@ -62,6 +64,9 @@
getDraw2dLast(value) {
if (value == true) this.draw2dLast();
},
getDraw2dPicture(value) {
if (value == true) this.draw2dPicture();
},
getReset(value) {
if (value == true) this.reset();
},
@ -137,9 +142,22 @@
this.draw2d(board);
},
// draw 2d automaton from the last known generated board
async draw2dLast() {
draw2dLast() {
if (this.lastBoard != undefined) this.draw2d(this.lastBoard);
},
// draw 2d automaton from an uploaded picture
draw2dPicture(e) {
this.picture.width = this.canvas.width;
this.picture.height = this.canvas.height;
this.ctx.drawImage(
this.picture,
0,
0,
this.canvas.width,
this.canvas.height
);
this.toggleStop();
},
// stop drawing routines and clear the canvas
reset() {
this.toggleStop();