A raster/2d function plot mark
https://observablehq.com/@observablehq/plot-heatmap-984
see comment in https://observablehq.com/@observablehq/javascript-replacements-for-python-data-science-tools#comment-7873045d922f909f
I like it. I think we should use foreignObject instead of toDataURL though (even if it currently breaks downloads on Observable; we could add a fix for that to downloading if we want to).
I wonder if using fillRect would be faster or slower than putImageData.
I think we’ll want a different option than resolution, but I’m not sure exactly what… For the current functionality I would rename the option to devicePixelRatio (or maybe pixelRatio) but I wonder if it should feel more like Plot.density where there’s an underlying grid of some resolution (that’s not necessarily 1:1 with pixels). But maybe starting with pixelRatio is fine and I’m overthinking.
It’s also interesting to think how a WebGL shader mark might function.
A while ago while playing around with my own density mark (with liberal help from Fil) I ran into an Safari bug where the foreignObject would not scale properly with the SVG.
You can see an example here – open it in Safari and increase the font size. Performance should be better than toDataURL, but I never figured out a workaround for the bug.
Fixed in #1196.