Live data from Hacker News

Stanford CS248: Implement an SVG Rasterizer

github.com

61–70 of 82 posts

Re: Stanford CS248: Implement an SVG Rasterizer

#61

This is a good example of a CS project you would do at Stanford and wouldn't get assigned at your local university.

I talk to people who think a CS degree has the same content and the same level of rigour and challenge everywhere. Absolutely baffles me.

What makes you so confident saying this?

Re: Stanford CS248: Implement an SVG Rasterizer

#62
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

I used to have troubles with retina displays, I always got a blurred image, no matter to what trick I tried. Is there a way to fix the rendering pixel ratio to 1?

Re: Stanford CS248: Implement an SVG Rasterizer

#63

This 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.

So? You can do anything on your own given enough effort and discipline.

Re: Stanford CS248: Implement an SVG Rasterizer

#64
post #62

Earlier 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

I used to have troubles with retina displays, I always got a blurred image, no matter to what trick I tried. Is there a way to fix the rendering pixel ratio to 1?

The usual approach with canvas for high dpi is to increase the size of the canvas and then scale it back down afterwards: https://codepen.io/graup/pen/jOPpopR

Re: Stanford CS248: Implement an SVG Rasterizer

#65
post #64
post #62

Earlier quoted context omitted.

I used to have troubles with retina displays, I always got a blurred image, no matter to what trick I tried. Is there a way to fix the rendering pixel ratio to 1?

The usual approach with canvas for high dpi is to increase the size of the canvas and then scale it back down afterwards: https://codepen.io/graup/pen/jOPpopR

This downloads 200x200. How to scale it back to 100x100? Ideally so that the image is the same no matter the display where it was exported on. Also I would like to not need to include any image processing libs. The usecase is to export a HTML element (e.g. a chart) and send to another API (e.g. attach it to a report), without downloading.

Re: Stanford CS248: Implement an SVG Rasterizer

#66
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.

not javascript, but screenshots work best - other approaches suffer from css and rendering bugs. best way is to just use your browser in headless mode from the command line. you can do a screenshot, and specify the window size.

https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Hea...

https://developers.google.com/web/updates/2017/04/headless-c...

and in dev panel https://developer.mozilla.org/en-US/docs/Tools/Taking_screen...

Re: Stanford CS248: Implement an SVG Rasterizer

#69
post #61

Earlier quoted context omitted.

I talk to people who think a CS degree has the same content and the same level of rigour and challenge everywhere. Absolutely baffles me.

What makes you so confident saying this?

Because I’ve been to multiple universities myself and I know it to not be true from my own eyes.

You can also just go to any university website yourself and compare their syllabi and see how different they are.

Re: Stanford CS248: Implement an SVG Rasterizer

#70

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.

Why did you name a closed source product openX? :)
Post reply on HN