Exporting Vector Graphics from HTML5 Canvas

2019-04-11 06:30发布

问题:

I'm curious if that's possible? I'm interested in building a vector drawing app within HTML5 that has the ability to save as vector, and not just JPG/PNG/BMP.

Thanks.

回答1:

Try fabric.js.

It draws stuff on Canvas, and has SVG import/export.
It handles 'objects', common SVG shapes and paths. The full SVG standard (fonts, for example) isn't supported, but maybe you only need to use a subset of it.



回答2:

No, it's not possible. After the drawing operations are complete all you're left with on the canvas are a bunch of pixels. You'd have to retain all the drawing options and then use them to create a separate vector drawing. If you want to save as a vector, why not create as a vector?