Published
Edited
Oct 5, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function activate(x, y) {
return !((x ^ y) % base);
}
Insert cell
function drawCells() {
const cellWidth = width / numOfCells;
const cellHeight = height / numOfCells;
return cells.reduce((acc, cell) => {
const [u, v, active] = cell;
if (active) {
const x = CSMath.lerp(0, width, u);
const y = CSMath.lerp(0, height, v);
return `${acc}
<rect x="${x - cellWidth / 2}" y="${
y - cellHeight / 2
}" width="${cellWidth}" height="${cellHeight}" fill="${colors.fg}" />
`;
}
return acc;
}, "");
}
Insert cell
cells = {
const cells = CSMath.linspace(numOfCells, true).map((v, j) =>
CSMath.linspace(numOfCells, true).map((u, i) => [u, v, activate(i, j)])
);

return cells.flat();
}
Insert cell
height = width
Insert cell
import { CSMath } from "@saneef/canvas-sketch-util"
Insert cell
import { footer } from "@saneef/notebooks-footer"
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more