[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:


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

I have experimented with the idea a bit more:


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.


More information about the metapost mailing list