function varyBar(gen, basis, { w = width, h = 50 } = {}) {
let width = w;
let height = h;
let canvas = document.createElement("canvas");
canvas.setAttribute("width", width);
canvas.setAttribute("height", height);
let ctx = canvas.getContext("2d");
let xScale = d3.scaleLinear().domain([0, 1]).range([0, width]);
let xScaleInv = (d) => xScale.invert(d);
let colorScale = culori.interpolate(["black", basis]);
for (let x = 0; x < width; x++) {
let d = xScaleInv(x);
let t = gen(d);
let c = colorScale(t);
ctx.fillStyle = culori.formatCss(c);
ctx.fillRect(x, 0, 1, height);
}
return canvas;
}