createBoad : flat array
This commit is contained in:
parent
745c197f09
commit
f19f3bb311
@ -46,7 +46,8 @@ function createBoard(state, rules, max) {
|
||||
} else {
|
||||
nextState = evolve1d(prevState, rules);
|
||||
}
|
||||
board = board.concat([nextState]);
|
||||
// flat array
|
||||
board.push(...nextState);
|
||||
prevState = nextState;
|
||||
}
|
||||
return board;
|
||||
|
@ -57,7 +57,7 @@ export function boardToPic(board) {
|
||||
const dead = board.cellProperties.deadColor;
|
||||
const img = new ImageData(board.width, board.height);
|
||||
const colors = [hexToRGB(live), hexToRGB(dead)];
|
||||
board.grid.flat().reduce((acc, cell, index) => {
|
||||
board.grid.reduce((acc, cell, index) => {
|
||||
const color = colors[(cell === 1) & 1];
|
||||
const i = index * 4;
|
||||
acc[i] = color[0];
|
||||
|
Loading…
Reference in New Issue
Block a user