nice colors

This commit is contained in:
2025-11-21 23:39:50 +00:00
parent a85f0d358f
commit b9b5bdb80a

View File

@@ -295,6 +295,9 @@ export function renderToCanvas(canvas, width, height, sn = 0, dn = 0) {
const img = ctx.createImageData(width, height); const img = ctx.createImageData(width, height);
const data = img.data; const data = img.data;
const colorOn = [0, 0, 139]; // dark blue (active cell)
const colorOff = [0, 0, 70]; // darker blue (inactive cell)
function step() { function step() {
// calculate new state // calculate new state
let [newState, newHead] = cyclicMaStep(rules, [states[row_num], head], r); let [newState, newHead] = cyclicMaStep(rules, [states[row_num], head], r);
@@ -303,11 +306,11 @@ export function renderToCanvas(canvas, width, height, sn = 0, dn = 0) {
// write row to ImageData // write row to ImageData
for (let x = 0; x < width; x++) { for (let x = 0; x < width; x++) {
const idx = (row_num * width + x) * 4; const idx = (row_num * width + x) * 4;
const val = newState[x] ? 255 : 0; const val = newState[x] ? colorOn : colorOff;
data[idx] = val; data[idx] = val[0]; // R
data[idx + 1] = val; data[idx + 1] = val[1]; // G
data[idx + 2] = val; data[idx + 2] = val[2]; // B
data[idx + 3] = 255; data[idx + 3] = 255; // A
} }
// update canvas (only this row) // update canvas (only this row)