Skip to content

raster fillRect#2415

Closed
mbostock wants to merge 4 commits intomainfrom
mbostock/raster-fill-rect
Closed

raster fillRect#2415
mbostock wants to merge 4 commits intomainfrom
mbostock/raster-fill-rect

Conversation

@mbostock
Copy link
Copy Markdown
Member

@mbostock mbostock commented Apr 9, 2026

Alternative to #2414 and #2145; bypass color parsing and color space conversion entirely by using context.fillRect to set colors. Unblocks #2143.

@mbostock mbostock requested a review from Fil April 9, 2026 23:50
Copy link
Copy Markdown
Contributor

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this together with #2143 and it works well.

The ramp opacity legend, which is currently based on d3.rgb, does not support CSS4 color strings; solvable with a SVG filter.

SSR (and snapshot tests) do not work when the colors are defined using a CSS4 string such as color(display-p3 1 0 0). Using a CSS4 color string parser would solve this, but I don't think it's a blocker. I'll add a test that is not "all black".

Here's how it looks: on the left, the test as it runs in the browser with everything p3; on the right, the snapshot test (in dull sRGB).

—

@mbostock
Copy link
Copy Markdown
Member Author

SSR (and snapshot tests) do not work when the colors are defined using a CSS4 string

Are you saying this is a limitation of Plot? Or a limitation of the node-canvas library we are using for snapshot testing? I don’t think that node-canvas supports colorSpace currently, so that’s fine, but I would want to know if you’re saying we have some limitation in Plot.

@mbostock
Copy link
Copy Markdown
Member Author

Also, are you aware that this is generally slower than the previous implementation?

test main mbostock/raster-fill-rect
rasterCa55Barycentric 148,123 257,264
rasterCa55Color 194,181 271,273
rasterCa55Nearest 132,142 228,234
rasterCa55None 33,44 38,36
rasterCa55RandomWalk 232,235 325,332
rasterFacet 94,96 144,142
rasterPenguinsBarycentric 100,90 136,134
rasterPenguinsBarycentricBlur 101,114 143,149
rasterPenguinsBlur 133,136 171,191
rasterPenguinsRandomWalk 121,124 165,175
rasterPrecision 111,102 141,171
rasterVapor 102,114 100,116
rasterVapor2 133,149 152,158
rasterVaporEqualEarth 127,138 151,150
rasterVaporEqualEarthBarycentric 139,133 169,176
rasterVaporPeters 123,125 159,153
rasterWalmartBarycentric 211,218 276,281
rasterWalmartBarycentricOpacity 102,87 183,159
rasterWalmartRandomWalk 250,249 287,320
rasterWalmartRandomWalkOpacity 163,148 246,247

@mbostock
Copy link
Copy Markdown
Member Author

Superseded by #2417.

@mbostock mbostock closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants