Published
Edited
Jan 6, 2022
Importers
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// My implementation of this is particularly awful. Suggestions welcome.

blur = (values) =>
values.map((d, i) => {
if (d == 0) return 0;

const cl = i % width > 0 ? i - 1 : i;
const cr = i % width < width - 1 ? i + 1 : i;
const tl = i % width > 0 ? i - width - 1 : i;
const tm = i - width;
const tr = i % width < width - 1 ? i - width + 1 : i;
const bl = i % width > 0 ? i + width - 1 : i;
const bm = i + width;
const br = i % width < width - 1 ? i + width + 1 : i;

return [i, cl, cr, tl, tm, tr, bl, bm, br]
.map((j) => {
if (j >= 0 && j < width * height && values[j] > 0) {
return (1 / 9) * values[j];
} else {
return (1 / 9) * d;
}
})
.reduce((a, b) => a + b);
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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