News for hackers. Stuff that matters.
Re:Stanford CS248: Implement an SVG Rasterizer by hypothete on Friday March 20, 2020 @05:29PM (#22641841)
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

Re:Stanford CS248: Implement an SVG Rasterizer by zakjan on Saturday March 21, 2020 @03:19AM (#22645141)
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 by graup on Saturday March 21, 2020 @03:37AM (#22645194)
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 by zakjan on Saturday March 21, 2020 @04:14AM (#22645265)
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 by beansie on Friday March 20, 2020 @05:44PM (#22641961)
Does the css need to be inlined?
Re:Stanford CS248: Implement an SVG Rasterizer by yzmtf2008 on Friday March 20, 2020 @06:05PM (#22642131)
Re:Stanford CS248: Implement an SVG Rasterizer by rayshan on Friday March 20, 2020 @06:58PM (#22642594)
Yup this is the problem. Workable but painful.