[metapost] Problem with showing paths

luigi scarso luigi.scarso at gmail.com
Fri Jan 21 09:20:33 CET 2022


On Fri, Jan 21, 2022 at 8:43 AM Laurence Finston <Laurence.Finston at gmx.de>
wrote:

> For a particular application, I'm calling MP from within a program via a
> pipe and I want to read the output and use it for setting variables in my
> application.  The intention is to use "point x of <path>" to take a path of
> length n and convert it into an equivalent path of length n*m where m is
> some whole number > 1 (within reason).
>
> The problem is the way the lines in the output of "show" are broken:  The
> lines are fairly short (max. 80 characters, including the newline) and the
> x- and y-coordinates of the points can be broken across two lines, which
> makes parsing unnecessarily difficult.


yes, it is a "feature". We have to deal with it.


>
>
It would also be nice to limit the number of decimal places for the
> coordinates, by rounding or even by truncating.
>
>
not with "double" but with "decimal" and "binary" we have numberprecision:
if numbersystem="decimal":
 numberprecision:=6;
fi
if numbersystem="binary":
 numberprecision:=6;
fi

decimal and binary are slower than double, btw.

As a workaround, I've written a macro to write the data I need to a file
> (see attachment), but it would be nicer if "show" could be used instead.
>
>
I think this is the right way, not a workaround: write your data to a file
, post-process the file with, for example, perl.

-- 
luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/metapost/attachments/20220121/35255a27/attachment.html>


More information about the metapost mailing list.