Hacker News new | ask | show | jobs
by rickosborne 1579 days ago
FWIW, your optimizations assume well-behaved SVG handling. This one, for instance, will cause problems:

> In fact, even each z can be dropped, provided no stroke is being used, removing three edges.

While that may be true according to the spec, I can tell you from a practical standpoint that it will break in Lightburn. It's SVG handling does unexpected things with implicitly closed paths, which suddenly go away when you explicitly move/stroke back to your starting point or "z".

I have not looked deeper into why, but if I had to make a WAG, I'd suspect it comes from their implementation trying to bridge the gap between SVG generators (which are optimized for "shape looks correct") and machine control instructions (which target the lower level "here are the steps to make this shape look correct"). You're then having to take something simple like a path and adding in the complexities of making machine control instructions for the practical rendering of that path, accounting for things like miters, etc. Seems like a complex layer, prone to tons of annoying little bugs like this.

I presume YouTube's designers/coders aren't worried about being able to run their UI widgets through a laser engraver, but I tend to chalk up these kind of "missed optimizations" to having some similar backstory of "we found this bug in this implementation, so here's the workaround".

2 comments

I’ve never heard of LightBurn. I presume you’re talking about the laser cutter software? If so, not knowing what it’s actually doing, I presume it’s just cutting along the stroke, rather than trying to do, I dunno, cross-hatch a fill or something? This case is specifically about fill, as I said, so if it’s just a matter of stroke then it’s quite correct in what it’s doing. If it actually is treating it as fill and getting it wrong, then that’s a bug that should be fixed and I have no patience with their implementation because it’s obviously wrong (as in: you’ll come across SVG like this all the time, there’s absolutely nothing anomalous about it).
These are the comment threads I love HN for.
+1 yes! this got deep very quickly