Public
Edited
Mar 27, 2023
Insert cell
Insert cell
gi = import("https://cdn.skypack.dev/@thi.ng/grid-iterators?min")
Insert cell
viewof iterator = Inputs.select(new Map(["hilbert2d","diagonal2d","interleaveColumns2d","interleaveRows2d","random2d","spiral2d","zcurve2d","zigzagColumns2d","zigzagDiagonal2d","zigzagRows2d"].map(d => [d,gi[d]])), {label: "Grid Iterator" })
Insert cell
Insert cell
Insert cell
hilbert = {
replay;
const pts = [];
for (const p of iterator({
cols: 32,
rows: 32,
tx: () => (x, y) => ({ x, y }) // optional, this transform changes [0,1] into {x: 0, y: 1}
})) {
pts.push(p);
yield pts;
}
}
Insert cell
Plot.rect(
iterator({
slope: 4,
cols: 80,
rows: 23
}),
{
x: "0",
y: "1",
interval: 1,
fill: (d, i) => i
}
).plot({ aspectRatio: 1 })
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