diff --git a/src/components/Canvas.vue b/src/components/Canvas.vue index a0153de..7865f36 100644 --- a/src/components/Canvas.vue +++ b/src/components/Canvas.vue @@ -29,7 +29,8 @@ export default { canvasHeight: 'getCanvasHeight', refreshRate: 'getRefreshRate', initial1dState: 'getInitial1dState', - drawingDirection: 'getDrawingDirection' + drawingDirection: 'getDrawingDirection', + lastBoard: 'getLastBoard' }), boardWidth: function() { return Math.floor( @@ -46,7 +47,8 @@ export default { this.canvas = this.$refs['canvas'] this.ctx = this.canvas.getContext('2d') this.$root.$on('draw1d', () => { this.draw1d() }) - this.$root.$on('draw2d', () => { this.draw2d() }) + this.$root.$on('draw2dNew', () => { this.draw2dNew() }) + this.$root.$on('draw2dLast', () => { this.draw2dLast() }) this.$root.$on('reset', () => { this.reset() }) this.$root.$on('stop', () => { this.stop() }) }, @@ -83,17 +85,11 @@ export default { this.rules, this.boardWidth ) + this.$store.commit('setLastBoard', board) this.drawCanvas(board) }, - async draw2d() { + async draw2d(board) { if (this.drawing === 0) return - const initialState = create2dState( - this.boardWidth, - this.boardHeight, - getRandomInt, - [0, 2], - ); - const board = evolve2d(initialState, conwayRules); const draw2dNext = async (b) => { if (this.drawing === 0) return @@ -104,6 +100,21 @@ export default { } return draw2dNext(board) }, + async draw2dNew() { + const initialState = create2dState( + this.boardWidth, + this.boardHeight, + getRandomInt, + [0, 2], + ); + const board = evolve2d(initialState, conwayRules); + this.$store.commit('setLastBoard', board) + this.draw2d(board) + }, + async draw2dLast() { + console.log(this.lastBoard) + this.draw2d(this.lastBoard) + }, stop() { this.$store.commit('setDrawingStatus', 0) }, diff --git a/src/components/Menu2dCA.vue b/src/components/Menu2dCA.vue index 81fcdbf..20e8287 100644 --- a/src/components/Menu2dCA.vue +++ b/src/components/Menu2dCA.vue @@ -1,5 +1,13 @@