←back to thread

Nice things with SVG

(fuma-nama.vercel.app)
571 points fmerian | 2 comments | | HN request time: 0.407s | source
Show context
LegionMammal978 ◴[] No.43666631[source]
One fun thing that can be done with SVG files: you can use entities in an inline DTD to define constants to be shared across different places in the file. You can see some great examples of this in the SVGs in David Ellsworth's "Squares in Squares" page [0].

The major browsers have no issues with this, though note that some tools like Inkscape won't parse the DTD nor expand the entities.

[0] https://kingbird.myphotos.cc/packing/squares_in_squares.html

replies(5): >>43666756 #>>43668277 #>>43668668 #>>43669828 #>>43671211 #
lenkite ◴[] No.43669828[source]
Maybe I am missing something, but can't find any !doctype or !element that would represent a DTD on that page. If you are talking simply about SVG defs and use - that isn't a DTD.
replies(1): >>43673059 #
1. LegionMammal978 ◴[] No.43673059[source]
They're all in the standalone files, e.g., look at the source of https://kingbird.myphotos.cc/packing/square-11.svg. It defines a bunch of entities to represent various lengths and angles, which obviously can't be <use>d. (CSS variables would be an alternative these days, but many non-browser tools such as librsvg will have trouble with those as well.)
replies(1): >>43676831 #
2. lenkite ◴[] No.43676831[source]
Aah thanks - these don't show up in the chrome inspector as by that time they are apparently already substituted.