[metapost] problems with memory in metapost

Reinhard Kotucha reinhard.kotucha at web.de
Sat May 8 14:32:17 CEST 2010


On 8 May 2010 Taco Hoekwater wrote:

 > It looks you (or gnuplot) are creating small rectangles instead
 > of simple dots, and that means that every data point expands into
 > quite a bit of postscript code:
 > 
 >    newpath 414.37424 124.80127 moveto
 >    416.37424 122.80127 lineto
 >    418.37424 124.80127 lineto
 >    416.37424 126.80127 lineto
 >    closepath stroke

If all these rectangles have the same shape and size, one could
post-process the file and define a procedure:

/R { newpath moveto 
     2 -2 rlineto 2 2 rlineto -2 2 rlineto closepath stroke 
} def 

Then the code-snippet above can be replaced by:

   414.37424 124.80127 R

This is actually equivalent to

   newpath 414.37424 124.80127 moveto
   2 -2 rlineto
   2  2 rlineto
   -2 2 rlineto
   closepath stroke

Note the use of relative coordinates and rlineto.  

This should save a lot of space but requires some post-processing.

Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
Reinhard Kotucha			              Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover	                      mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------


More information about the metapost mailing list