Live data from Hacker News

Stanford CS248: Implement an SVG Rasterizer

github.com

11–20 of 82 posts

Re: Stanford CS248: Implement an SVG Rasterizer

#11

Earlier quoted context omitted.

I assume the point is that you have to implement a pure software rasterizer. It's not actually that difficult, but it feels like a lot for an undergrad who's not familiar with the space. I assume this is done as part of a class that gives you context. For an example of a rasterizer, you can take a look at my pure JS implementation of canvas (which is roughly the same imaging model as SVG). All lines and shapes are fl…

It's get somewhat tricky when you want things like gpu support, text rendering etc. You have to do things like stencil texture to speed things up etc etc.

This is a beginner CS course, it's a lot simpler than that.

Re: Stanford CS248: Implement an SVG Rasterizer

#14

I've already implemented an SVG renderer at https://www.amanithsvg.com based on our openvg engine with software rasterization https://www.amanithvg.com Both are closed source, but there are evaluation version available, if someone is interested in compare rendering quality and speed.

Can you recommend some resources for someone trying to do the same?

Re: Stanford CS248: Implement an SVG Rasterizer

#15
post #13

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.

Does Path2D cover it? If it does, seems like you could just draw to a canvas and save the result. https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path...

Re: Stanford CS248: Implement an SVG Rasterizer

#17

I've already implemented an SVG renderer at https://www.amanithsvg.com based on our openvg engine with software rasterization https://www.amanithvg.com Both are closed source, but there are evaluation version available, if someone is interested in compare rendering quality and speed.

Can you recommend some resources for someone trying to do the same?

You can look at software rasterization from good opensource libs: Freetype, Agg, Cairo.

Re: Stanford CS248: Implement an SVG Rasterizer

#20
post #13

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.

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

Post reply on HN