You are looking at historical revision 41924 of this page. It may differ significantly from its current revision.

An SVG path data library for Chicken Scheme

This library can turn SVG path data to tagged sexp format (compatible with alists and with SXML). You can switch between absolute and relative coordinates, and turn it into a minified string.

The procedures work on both this library's own tagged format and on path data strings.

The data format uses single-letter symbols for the commands and exacts for the numbers. Every node is a separate entry, including multiple subsequent nodes of the same command.

path->string

(path->string "M100 100 L101,101 90 102")
⇒ "M100 100l1 1-11 1"

Change a path (in sexp or string format) into a minified string.

->apath

(->apath "M100 200L200 100-100-200")
⇒ ((M 100 200) (L 200 100) (L -100 -200))

Change a path (in sexp or string format) into sexp format with absolute coordinates.

->rpath

(->rpath "M100 200L200 100-100-200")
⇒ ((m 100 200) (l 100 -100) (l -300 -300))

Change a path (in sexp or string format) into sexp format with relative coordinates.

->mpath

(->mpath "M100 200L200 100-100-200")
⇒ ((M 100 200) (L 200 100) (L -100 -200))

Change a path (in sexp or string format) into sexp format with whatever coordinate format will print the shortest. This is almost never what useful when doing path programming, but path->string uses it internally.

Soure code

For a repo,

git clone https://idiomdrottning.org/svgpath