display = {
buttons;
const ctx = DOM.context2d(width / 2, height, 1);
const canvas = ctx.canvas;
const cellSize = 10;
const color = (value) => {
value *= 255;
return `rgb(${value},${value},${value})`;
};
const draw = () => {
ctx.clearRect(0, 0, width / 2, height);
for (let x = 0; x < width; x += cellSize) {
for (let y = 0; y < height; y += cellSize) {
let v = mutable interpolator([x + cellSize / 2, y + cellSize / 2]);
ctx.fillStyle = color(v[0]);
ctx.fillRect(x, y, cellSize, cellSize);
}
}
ctx.strokeStyle = "red";
for (let [[x, y], [v]] of d3.zip(points, values)) {
ctx.beginPath();
ctx.arc(x, y, 10, 0, Math.PI * 2);
ctx.stroke();
}
};
const compute_rbf = () => {
mutable interpolator = RBF(points, values, kernel);
};
canvas.onclick = (e) => {
let [x, y] = [e.offsetX, e.offsetY];
if (e.button == 0) {
points.push([x, y]);
values.push([viewof defValue.value]);
} else reset();
compute_rbf();
draw();
};
compute_rbf();
draw();
return canvas;
}