Sunday, February 21, 2016

Concrete SVG poetry

So Arlen hipped me to this neat online utility
svgnest.org. This is an iterative program to
find the best packing of 2D shapes -- useful, for example, if you
want to lasercut parts of of plastic with minimal waste.

I immediately was reminded of some of the concrete poetry I had seen and was inspired to use svgnest to make some. Not being a terrific poet, I borrowed some lines from Ikkyū Sōjun (1394–1481)

Nobody understands why we do what we do
this cup of sake does

And wrote that into an inkscape .svg file. After converting the text to paths, I uploaded it to svgnest with the following result:

Not that bad for a 5-minute experiment! I thought the poetry would be
better (not to mention more legible) if words were preserved, and
here's where it got painful. First I tried to combine the letter paths
into words by grouping them. This was ignored by svgnest -- not
unexpected; grouping is probably not in the SVG spec. Then I looked
for ways to link the SVG paths Turns out you can't do that at the path
level: the SVG specification forbids T junctions. But I did try
various combinations of path math (Union, Combine, Intersection, etc.)
and I hit on a combination that worked: "Combine" (Crtl-K) followed by
a "Linked Offset." I don't quite understand what this does, and was
too lazy to look at the generated SVG, but it seemed to work.

So next experiment, again with the Ikkyū:

oh green
green willow and wonderfully red flower but I know the colors are
not there

Again more pain - svgnest would just
hang on the file for minutes at a time, even though there were only 14
words to nest (while it neatly handled more than 50 letters in the
previous example). While it was thinking (I eventually let it run
overnight with similar lack of results) I tried nesting one line at a time. This
actually worked, and resulted in two SVG files which I combined by
hand into the following: