Live data from Hacker News

An SVG is all you need

jon.recoil.org

71–80 of 155 posts

Re: An SVG is all you need

#72
I once solved a machining problem using SVG and a bit of javascript and python.

I was prototyping an orrery. It involved cutting out a lot of ad-hoc gears and frame bits on my CNC out of a sheet of brass. It was relatively easy to generate the g-code for the individual parts using fusion360, but then it was a lot of faff to zero the machine such that it cut the part from a fresh part of the brass sheet without wasting too much metal in between the parts. It involved a lot of guesswork, and eyeballing. And even with that there was a lot of brass “wasted” between the parts especially since you could only move your part in x-y but not easily rotate it.

As a solution I wrote a python script which converted the g-code into svg, and a simple one page website where i could drag the svg around and rotate it on a visual representation of the sheet. Once i found a good safe spot for it to be cut the page told me the x,y, theta coordinates for it. And then with a separate python script i could transform the g-code using the coordinates and rotation. This way the svg renderer was doing the heavy lifting of visualising the cutting paths, and i only needed to concentrate on the relatively easy transforms.

Re: An SVG is all you need

#73
Downsides of using SVG:

- cannot wrap text

- cannot embed font glyphs - your SVG might be unreadable if the user doesn't have the font installed. You can convert letters to curves, but then you won't be able to select and edit text. It's such an obvious problem, yet nobody thought of it, how? Photoshop solved this long time ago - it saves both text and its rendering, so the text can always be rendered.

- browsers do not publish, which version and features they support

- may contain Javascript and references to external resources, which makes it difficult to view in a secure, isolated environment

One of solutions is having two SVGs: author version, which you edit in Inkscape and which uses Inkscape-specific extensions, and published version, which is generated from the first, that uses only basic features and has text converted to curves.

Re: An SVG is all you need

#74
post #70
post #68

Earlier quoted context omitted.

It's a bit sad that Postscript never caught on as much as it could have. In an alternate timeline, it could have been the HTML (and SVG) we got in ours.

Postscript is still everywhere. Its just out of sight, being used as a compile target. PDF may have "officially" replaced it, but it is still embedded almost everywhere you look.

PDF is a sad replacement for PS. As far as I can tell, it was an attempt to obscure PS, because alternative vendors were getting better as Postscript than the originators.

(There was some justification in terms of 'Oh, a binary format like PDF is more space efficient.' But PDF never really was more efficient than compressed PS.)

It's not that PS has vanished, but PS isn't nearly as 'everywhere' as HTML came to be.

Re: An SVG is all you need

#76

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…

The idea of rerunning experiments only seems feasible when the entire experiment was based on modelling, presumably modelling that can easily/quickly be rerun in a browser environment.

The idea of being able to view and parse the dataset in different ways is interesting though, effectively allowing readers to interpret the experiment's resulting dataset from different angles than the author published.

Re: An SVG is all you need

#77

Two years ago I re-vamped my "Spurious Correlations" side project, which is mostly just a bunch of charts. However, I couldn't find a charting software I liked that would display clean, simple visuals with the constraints I wanted. (I had used pCharts and HighCharts in the past, but didn't like charting in Javascript or PHP.) I decided to "roll my own" and write Python scripts that outputted SVG markup. I was worried…

Thanks for making that website. I used examples from it in the first day of my statistics course ("by the end of this course you won't make these kinds of mistakes").

Re: An SVG is all you need

#78
post #22

An SVG and JS, right? It's not interactive on its own.

The JS is embedded within the SVG file and not exposed outside it

The JS is exposed in the full page's context the same as if you included a under a instead of . In much the same way, whether the is before or after the tag doesn't matter - it's just a script working on a single DOM (with different namespaces for certain elements) either way.

Re: An SVG is all you need

#79

Downsides of using SVG: - cannot wrap text - cannot embed font glyphs - your SVG might be unreadable if the user doesn't have the font installed. You can convert letters to curves, but then you won't be able to select and edit text. It's such an obvious problem, yet nobody thought of it, how? Photoshop solved this long time ago - it saves both text and its rendering, so the text can always be rendered. - browsers do…

Safari supports base64-embedding font files in a ’s @font-face {} (iirc it's something like `@font-face { src: url('data:application/x-font-woff;charset=utf-8;base64,...'); }`) that can then be referenced as normal throughout the SVG. I don't recommend this though, nobody wants to deal with 500KB SVGs.

Re: An SVG is all you need

#80
post #74
post #70

Earlier quoted context omitted.

Postscript is still everywhere. Its just out of sight, being used as a compile target. PDF may have "officially" replaced it, but it is still embedded almost everywhere you look.

PDF is a sad replacement for PS. As far as I can tell, it was an attempt to obscure PS, because alternative vendors were getting better as Postscript than the originators. (There was some justification in terms of 'Oh, a binary format like PDF is more space efficient.' But PDF never really was more efficient than compressed PS.) It's not that PS has vanished, but PS isn't nearly as 'everywhere' as HTML came to be.

PDF is also a lot less powerful, purposefully so. You can start an infinite loop just by double-clicking a PS file, for instance.

It is extremely useful to have a full programing language as a file format, though.

I miss macOS’s Preview.app auto-converting PS to PDF when double-clicked. It was a way to easily distribute a document that could randomize question orders each time it opened, print multiple bingo cards from a single file, etc.

The stack-based and reverse Polish notation thing was also fun.

Post reply on HN