Vector graphics on Rust?

Hello. Maybe someone encountered something Fabric this on Rust( webgl-based )?

I would appreciate any suggestion.

If you mean the canvas-rendering part, then browser APIs only exist in JS, so they have to be used from JS.

If you want to draw outside of a web browser, or implement your own web browser:


I guess this is true in some sense, but you can definitely call the canvas API from Rust compiled to WebAssembly, e.g. this example. The only JavaScript is a tiny shim to call the compiled Wasm module.

1 Like

I know, but I don't think it makes much sense for driving <canvas>.

WebGL canvas needs relatively little computation from the client side. The heavy lifting is done by the canvas itself, and you mainly just update the state by issuing draw calls. Involving Rust will only add overhead to the draw calls.

It would be different if you wanted to do pixel-pushing and draw SVG without canvas. In that case WASM+SIMD may work much better than plain JS. Rust would make sense for vector graphics if you wanted to do complex transformations (e.g. optimize SVG, optimally lay out graphs, or generate complex geometry), but AFAIK that's not what fabric.js is doing, it's mostly just 1:1 mapping of SVG DOM to canvas with a touch of affine transformations and convenience methods. I expect such mature library to be already well-optimized for this.


Lyon is something I had been looking for. Thank you @kornel!

Fair enough, thanks for elaborating!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.