Published
Edited
Sep 5, 2018
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
grid = ` x x
x
x x xxxxx
x x x x x x
xxx x x x x`
Insert cell
Insert cell
coords = {
let coords = [];
let y = 2.5;
for (let line of grid.split("\n")) {
let x = -5.5;
for (let char of line.split("")) {
if (char === "x") {
coords.push([x, y]);
}
x++;
}
y--;
}
return coords;
}
Insert cell
Insert cell
coord = ([_x, _y]) => {
let x = _x * 2;
let dx = x - 2;
let y = _y * 2;
let dy = y - 2;
let fx = x.toFixed(2),
fy = y.toFixed(2),
fdx = dx.toFixed(2),
fdy = dy.toFixed(2);
return `((step(${fx}, x) + step(${fdx}, x)) * (step(${fy}, y) + step(${fdy}, y)) * 0.5)`;
}
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