This is a small utility used to convert SVG paths to mathematical equations. The equations can then be plotted to recreate the image. This only allows outlining SVG paths, and not other shapes, clip paths, patterns or other fancy stuff. For this reason, every unsupported element must be converted to a path using a vector editor like Inkscape, or an optimizer like SVGO.
This was primarily aimed to be used with Desmos. Equations with latex formatting can be copy-pasted directly in the calculator, and it is possible to generate a script used to set some basic styling on equations.
Jar files can be found under releases.
The jar file can be run with:
java -jar svgeq.jar <svg-file> [options]
The CLI expects at least one parameter specifying the .svg
file, but there can be more than one.
Transformations use SVG grammar for
the transform
attribute. The Y axis is always automatically inverted. Arcs are always converted to bezier curves.
Here's an example usage of options:
-p 3 -e parametric --transform="translate(10 10) rotate(30) skewX(10)" --latex --lenient
If using the style script, the stroke width will most likely have to be tuned manually. This is because Desmos doesn't have an absolute stroke width, but rather the width is kept the same for all zoom levels. Therefore, the width must be adjusted for whatever zoom level will be used to view. Also note that the script can only set widths ranging from 0.1 to 25.5.
path
, and the only supported attributes are d
, transform
, opacity
,
stroke-opacity
, stroke
and stroke-width
. Make sure to manually check your SVG file content before
generating the equations. Notably, there shouldn't be any groups in the SVG structure.See changelog.
All code is licensed under Apache License, Version 2.0.