This snippet dumps the contents of the current path to stdout. It uses the ghostscript procedure =only
which may not be available on all interpreters. An equivalent procedure on Adobe interpreters is called =print
.
pathforall
is a looping operator which takes 4 procedure bodies as arguments which are called for the specific types of path elements, the result of moveto
, lineto
, curveto
, closepath
, and all other path-contruction operators which boil-down to these elements.
{ exch =only ( ) print =only ( ) print /moveto =}
{ exch =only ( ) print =only ( ) print /lineto =}
{ 6 -2 roll exch =only ( ) print =only ( ) print
4 2 roll exch =only ( ) print =only ( ) print
exch =only ( ) print =only ( ) print /curveto =}
{ /closepath = }
pathforall