What's a good JavaScript-based solution to render SVG into an image? html2canvas doesn't work well with SVG, especially those heavily styled with CSS.
https://github.com/fabricjs/fabric.js
Stanford CS248: Implement an SVG Rasterizer
31–40 of 82 posts
Re: Stanford CS248: Implement an SVG Rasterizer
#32This is a good example of a CS project you would do at Stanford and wouldn't get assigned at your local university.
Re: Stanford CS248: Implement an SVG Rasterizer
#33What's a good JavaScript-based solution to render SVG into an image? html2canvas doesn't work well with SVG, especially those heavily styled with CSS.
https://github.com/shakiba/svgexport Is that what you’re looking for?
Re: Stanford CS248: Implement an SVG Rasterizer
#34What's a good JavaScript-based solution to render SVG into an image? html2canvas doesn't work well with SVG, especially those heavily styled with CSS.
Kinda defeats the whole purpose of SVG. Only photos should be bitmaps. Graphics should be vectors. This is the 21st century, folks...
Re: Stanford CS248: Implement an SVG Rasterizer
#35What's a good JavaScript-based solution to render SVG into an image? html2canvas doesn't work well with SVG, especially those heavily styled with CSS.
Shameless Plug for a library I helped write: https://github.com/SVG-Edit/svgedit
Re: Stanford CS248: Implement an SVG Rasterizer
#36Earlier quoted context omitted.
If you're not in a Node.js context, the Canvas API does a decent job of rasterizing SVGs nowadays. Once rasterized, you can call canvas.toDataURL() to get a download link. Here's a demo: https://codepen.io/hypothete/pen/WNvKLEE
Does the css need to be inlined?
Re: Stanford CS248: Implement an SVG Rasterizer
#37This is a good example of a CS project you would do at Stanford and wouldn't get assigned at your local university.
Re: Stanford CS248: Implement an SVG Rasterizer
#38This is a good example of a CS project you would do at Stanford and wouldn't get assigned at your local university.
You can easily do this on your own.
My friend tried to get a CS degree at Pepperdine and the curriculum was 15 years out of date. To students who are new to the field, it is hard to figure out where to start even if they could do it independently.
Re: Stanford CS248: Implement an SVG Rasterizer
#39Earlier quoted context omitted.
What do you mean GPUs don't support them? Most opengl tutorials I've read have people building triangles in 2d to learn fragment shaders and vertices before going 3d. Most of them also support parametric curves, so even hardware accelerated bezier curves should be possible.
Wait, why do you say GPUs support parametric curves? GPUs are based on triangles mostly.
Re: Stanford CS248: Implement an SVG Rasterizer
#40Earlier quoted context omitted.
What do you mean GPUs don't support them? Most opengl tutorials I've read have people building triangles in 2d to learn fragment shaders and vertices before going 3d. Most of them also support parametric curves, so even hardware accelerated bezier curves should be possible.
Wait, why do you say GPUs support parametric curves? GPUs are based on triangles mostly.
What you are saying is outdated by maybe a couple of decades.