diff --git a/src/components/CanvasBoard.vue b/src/components/CanvasBoard.vue index 1eedb8f..1de00d2 100644 --- a/src/components/CanvasBoard.vue +++ b/src/components/CanvasBoard.vue @@ -111,19 +111,19 @@ // draw 2D automaton on the canvas in a loop const draw2d = (board) => { - store.board.grid = Object.freeze(evolve2d(board.grid, selectedRules())); drawCanvas(store.board); + const newBoard = Object.freeze(evolve2d(board.grid, selectedRules())); + if (store.board.grid == newBoard) store.toggleStop(); + store.board.grid = newBoard; }; // draw 2d automaton in a loop, starting from passed state const draw2dNext = async (board) => { setTimeout(() => { - requestAnimationFrame(() => { - if (!store.canDraw) return; - draw2d(board); - return draw2dNext(store.board); - }); - }, store.refreshRate); + if (!store.canDraw) return; + draw2d(board); + return draw2dNext(store.board); + }, store.renderer.refreshRate); }; // draw 2d automaton from a new state