Live data from Hacker News

An SVG is all you need

jon.recoil.org

51–60 of 155 posts

Re: An SVG is all you need

#51
post #39

I recently found out that it is surprisingly hard to convert an SVG file that consists of series of line segments into a list of those line segments in Python. I tried with ChatGPT and Claude but both were not able to find a solution that respects the entire specification, especially transforms. Initially, my expectation was that there must be a library for this kind of thing, but alas.

I seem to remember that the DOM nodes themselves expose some pretty useful functions. I think it was in the context of detecting edge crossings for a graph router, but you were able to interact with the computed/rendered coordinates in this context.

Sorry that's not more useful and explicit, it was a while back and never went anywhere.

Re: An SVG is all you need

#52
post #29

I really like SVG, I did a lot of things with it and some interesting ones. The only blame I have is that it is sometime slow. Like for QR Code, precise maps or +100 pixels wide squares. More than 100 "DOM" elements and it will take multiple seconds to show. The animations also are slow too, compared to canvas, plain CSS or Lottie but nothing very cursed, it's mostly fine.

I embedded a chess engine in SVG image of a chess board (https://github.com/jnykopp/svg-embedded-chess) so that the engine moved the pieces automatically and played against itself, just by viewing the SVG.

This was done for a friend of mine who made an art installation that projected like some 50x20 (can’t remember exactly) of these images in a grid on a wall, for perpetual chess madness.

The number of chess SVGs a laptop’s browser was able to run simultaneously did feel suprisingly low, but luckily it was enough for that particular piece of art.

Re: An SVG is all you need

#53

I agree with the author when they write: """ In my idealistic vision of how scientific publishing should work, each paper would be accompanied by a fully interactive environment where the reader could explore the data, rerun the experiments, tweak the parameters, and see how the results changed. """ I do like seeing larger labs/companies releasing research full of SVGs. In recent memory, I quite liked this from NVIDI…

Interactive and SVGs don't really mix, although intuitively it would seem that they do. Rendering remotely complex SVGs tale multiple seconds, while any kind of interactivity demands ~30+ frames per seconds.

Without interactivity, postscript is vector graphics too.

Re: An SVG is all you need

#54
post #53

I agree with the author when they write: """ In my idealistic vision of how scientific publishing should work, each paper would be accompanied by a fully interactive environment where the reader could explore the data, rerun the experiments, tweak the parameters, and see how the results changed. """ I do like seeing larger labs/companies releasing research full of SVGs. In recent memory, I quite liked this from NVIDI…

Interactive and SVGs don't really mix, although intuitively it would seem that they do. Rendering remotely complex SVGs tale multiple seconds, while any kind of interactivity demands ~30+ frames per seconds. Without interactivity, postscript is vector graphics too.

How complex are you talking about? I've done animations with hundreds of elements and it's fine.

Re: An SVG is all you need

#55
I love seeing old formats hold up this well. SVG surviving 20 years of browser evolution is a pretty strong argument for “boring tech” done right. It makes me wonder why we don’t see more research papers ship with fully self-contained interactive SVGs today — the tooling and browser performance are better than ever.

Re: An SVG is all you need

#56
post #39

I recently found out that it is surprisingly hard to convert an SVG file that consists of series of line segments into a list of those line segments in Python. I tried with ChatGPT and Claude but both were not able to find a solution that respects the entire specification, especially transforms. Initially, my expectation was that there must be a library for this kind of thing, but alas.

Not sure about python, but https://docs.rs/usvg in Rust is pretty good

Re: An SVG is all you need

#57

Author here: I've just made a ninja edit of the post as it didn't really make clear a quite important point - the SVG is literally 20 years old, and still works, astonishingly. I'm not sure much else I wrote around the time would still work without some editing!

The reverse is kind of true: In the beginning, SVGs were not really an option since it lacked adoption across all major browsers, or more specifically its integration was very heterogenous. So a SVG you authored 20 years ago for some browser will likely work everywhere today.

Except in an email. Because email is pain.

Re: An SVG is all you need

#58
I remember an employee of mine, who was possibly the best engineer I ever knew, wrote up a specification document for his own vignetting algorithm, in Postscript.

The algorithm provided a 100X performance improvement over the classic Monte Carlo stuff that Tokyo had written.

The charts in the document were executable Postscript, running his algorithm.

That got the attention of the Ph.Ds in Tokyo. He was a high school-educated neurodivergent.

Re: An SVG is all you need

#59

I agree with the author when they write: """ In my idealistic vision of how scientific publishing should work, each paper would be accompanied by a fully interactive environment where the reader could explore the data, rerun the experiments, tweak the parameters, and see how the results changed. """ I do like seeing larger labs/companies releasing research full of SVGs. In recent memory, I quite liked this from NVIDI…

Without the OP's proposed use of SVG, what format would someone use? PDFs won't handle it well - unless PDF's interactivity capabilities are much better than I think. We never developed a client-side multimedia file format; all we have are text formats like Word and PDF, which embed images decently, and embed multimedia and interactivity (beyond form filling) in awkwardly and in a limited manner.

Re: An SVG is all you need

#60
post #59

I agree with the author when they write: """ In my idealistic vision of how scientific publishing should work, each paper would be accompanied by a fully interactive environment where the reader could explore the data, rerun the experiments, tweak the parameters, and see how the results changed. """ I do like seeing larger labs/companies releasing research full of SVGs. In recent memory, I quite liked this from NVIDI…

Without the OP's proposed use of SVG, what format would someone use? PDFs won't handle it well - unless PDF's interactivity capabilities are much better than I think. We never developed a client-side multimedia file format; all we have are text formats like Word and PDF, which embed images decently, and embed multimedia and interactivity (beyond form filling) in awkwardly and in a limited manner.

What's wrong with SVG? Notebooks have their issues but are kinda this conceptually. I guess FLAs and Flash too. But you say we never developed a "client-side multimedia file format". Is that not exactly what html + js are for?
Post reply on HN