[metapost] how to express "struct"

Nicola nvitacolonna at gmail.com
Sun Mar 12 10:05:13 CET 2017


On 12/03/2017 01:35, Laurent Méhats wrote:
> Le 11/03/2017 à 19:23, Qiong Cai a écrit :
>> Hi,
>>
>> I am trying to define a C-like struct in metapost:
>>
>>        struct Pixel {
>>              numeric x;
>>              numeric y;
>>              numeric val;
>>        };
>>
>> What's the best way to define such a struct in MetaPost?

You may copy and paste the two macros described here:

http://www.gust.org.pl/projects/pearls/2011p/nicola-vitacolonna/bachotex2011-nicola-vitacolonna-pearl1.pdf

That gives you “structs” and “templates” (well, sort of…).

I have experimented with the idea a bit more:

http://users.dimi.uniud.it/~nicola.vitacolonna/software/metappeal/

I am in the (slow) process of rewriting most of that code (and throwing
away things that do not make sense any longer, such as bigints),
although the core macros from the PDF above still work pretty much the
same. If there is some interest in the project (and, possibly, people
interested in collaborating), I can publish an updated version.

Nicola



More information about the metapost mailing list