fix evolve 2D #11
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user