draw then store
This commit is contained in:
parent
9951ada7b3
commit
71f8a9c8b5
@ -111,19 +111,19 @@
|
|||||||
|
|
||||||
// draw 2D automaton on the canvas in a loop
|
// draw 2D automaton on the canvas in a loop
|
||||||
const draw2d = (board) => {
|
const draw2d = (board) => {
|
||||||
store.board.grid = Object.freeze(evolve2d(board.grid, selectedRules()));
|
|
||||||
drawCanvas(store.board);
|
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
|
// draw 2d automaton in a loop, starting from passed state
|
||||||
const draw2dNext = async (board) => {
|
const draw2dNext = async (board) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
requestAnimationFrame(() => {
|
if (!store.canDraw) return;
|
||||||
if (!store.canDraw) return;
|
draw2d(board);
|
||||||
draw2d(board);
|
return draw2dNext(store.board);
|
||||||
return draw2dNext(store.board);
|
}, store.renderer.refreshRate);
|
||||||
});
|
|
||||||
}, store.refreshRate);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// draw 2d automaton from a new state
|
// draw 2d automaton from a new state
|
||||||
|
Loading…
Reference in New Issue
Block a user