Live data from Hacker News

Stanford CS248: Implement an SVG Rasterizer

github.com

1–10 of 82 posts

Re: Stanford CS248: Implement an SVG Rasterizer

#3

2d graphics are kinda hard. The problem is that gpus don't support them out of the box so you have to do a Lot yourself.

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 flattened into a pure line polygon, then drawn with a scanline rasterizer. Getting the basics working is fairly easy. Handling the endless edge cases, however.... :)

https://github.com/joshmarinacci/node-pureimage

Re: Stanford CS248: Implement an SVG Rasterizer

#4

2d graphics are kinda hard. The problem is that gpus don't support them out of the box so you have to do a Lot yourself.

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.

Re: Stanford CS248: Implement an SVG Rasterizer

#6

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.

GPUs aren't really designed for 2D graphics out of the box. I've written about this before [0].

Text rendering can be tricky, but not that much trickier -- it's just the same curves at smaller scales.

Not sure what you mean by stencil textures. Are you talking about the NV_path_rendering approach where you stencil out the path? Yeah, that's not really a thing that people do these days.

[0] https://blog.mecheye.net/2019/05/why-is-2d-graphics-is-harde...

Re: Stanford CS248: Implement an SVG Rasterizer

#7

2d graphics are kinda hard. The problem is that gpus don't support them out of the box so you have to do a Lot yourself.

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…

Yeah, writing a scanline rasterizer from scratch is fun. For beginners, I advocate the sample-based approach I've written about, as functional "is inside shape" can be easier to reason about for simple cases. It's harder for non-convex polygons though :)

https://magcius.github.io/xplain/article/rast1.html

The edge cases are similar -- precision in computing the path intersections and winding curves.

Re: Stanford CS248: Implement an SVG Rasterizer

#8
post #6

Earlier quoted context omitted.

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.

GPUs aren't really designed for 2D graphics out of the box. I've written about this before [0]. Text rendering can be tricky, but not that much trickier -- it's just the same curves at smaller scales. Not sure what you mean by stencil textures. Are you talking about the NV_path_rendering approach where you stencil out the path? Yeah, that's not really a thing that people do these days. [0] https://blog.mecheye.net/20…

Yeah I'm talking about that. What do people use then?

Re: Stanford CS248: Implement an SVG Rasterizer

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

Post reply on HN