constrain
constrain copied to clipboard
SVG backend
This might be a little hard, but I was having a look at the postscript backend (which looks very nice and useful), and it made me think that I could get a lot out of having an SVG backend. The benefits are:
- Vector drawing rather than pixel drawing: the user can zoom in
- Accessibility features: in addition to zooming, we can attach data to assist screenreaders, etc.
- The ability to embed MathML directly, rather than embedding 'screenshots' of math
https://github.com/gliffy/canvas2svg This looks promising...
Update: I have some hacked version of the library above now which is allowing me to (1) draw to SVG rather than to canvas, and (2) embed MathML directly into the SVG as a <foreignObject>
, which solves the accessibility problems.
The interactive features are not supported, and the code is very janky. But maybe as a proof of concept, it is cool 😎
You can look at / play with my hacked up version here: https://github.com/jonsterling/constrain/blob/svg/examples/svg.html
An SVG back end is a nice idea. I wonder if the right way to render is to interpose at a higher level of abstraction. For example, SVG has a rounded rectangle as a builtin, whereas interposing at the canvas level will mean turning it into a bunch of small SVG drawing commands.