From 89723351988fc66af37acfd205ae43cf1c587af2 Mon Sep 17 00:00:00 2001 From: Gator Date: Tue, 6 Dec 2022 17:41:32 +0100 Subject: [PATCH] test load picture on canvas --- src/components/CanvasBoard.vue | 20 ++++++++++++++- src/components/Menu2dCA.vue | 40 ++++++++++++++++++++++++----- src/components/MenuElementaryCA.vue | 11 +++++--- src/components/MenuRow.vue | 6 ++++- src/stores/index.js | 9 +++++++ 5 files changed, 75 insertions(+), 11 deletions(-) diff --git a/src/components/CanvasBoard.vue b/src/components/CanvasBoard.vue index f7ce42f..9291b1c 100644 --- a/src/components/CanvasBoard.vue +++ b/src/components/CanvasBoard.vue @@ -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(); diff --git a/src/components/Menu2dCA.vue b/src/components/Menu2dCA.vue index 58a410b..2653cfa 100644 --- a/src/components/Menu2dCA.vue +++ b/src/components/Menu2dCA.vue @@ -15,14 +15,14 @@

- - + +