[metapost] Designing Brahmi DDHA

Laurent Méhats laurent.mehats at gmail.com
Tue Jul 31 14:53:24 CEST 2012

Le 31/07/2012 11:34, Shriramana Sharma a écrit :
> Hello list. I have previously posted about my work on palaeographic
> Indic scripts. I'm right now tackling the grandmother of them all --
> Brahmi. Since Brahmi is largely like stick figures (with all due
> respect to King Ashoka) I didn't have the patience to do it the Meta*
> way yet. I clipped glyphs from Senart's Les Inscriptions de Piyadasi
> and drew straight lines on top of them. The few simple curves were not
> an issue, but when I came to DDHA I was stumped because it was the
> only highly-curved glyph and my Inkscape-designed glyph did not look
> good at all. (I still have my suspicions about its age but Indoskript
> says it's from BCE 252 so, well...)
> So I had the idea of getting the nodes from Inkscape and making MPost
> draw a "smooth" curve instead and I have to say I am most pleased with
> the results. :-) Thank you all whose work has gone into MPost (and the
> other tools I used)! :-)
> Those interested might like to investigate the attached files.
> BTW because Inkscape has y values increasing downwards but Mpost has
> them increasing upwards, the final glyph is upside down. (I had to be
> careful with using the directions up/down inside the .mp file because
> of this.) Looking at the MPost manual there doesn't seem to be any
> built-in transform to do "flip vertical" on a path as is found in
> popular vector-drawing applications.
> I am thinking of something like:
> def flipvertical ( path p )
> 	begingroup ;
> 		numeric pleft, pright, phalfheight ;
> 		phalfheight = ( ypart llcorner p + ypart urcorner p ) / 2 ;
> 		pleft = xpart llcorner p ;
> 		pright = xpart urcorner p ;
> 		p := p reflectedabout ( ( pleft, phalfheight ), ( pright, phalfheight ) ) ;
> 	endgroup ;
> enddef ;
> But I am not sure whether the above will work correctly. I think I
> cannot create a transform out of this because a transform must be
> defined even for single points but flip horizontal/vertical are valid
> only for paths with more than one points. Can anyone please help me
> how to implement a flipvertical?
> Thanks!


Here is a vflip macro that should take anything drawable as an argument.

vardef vflip (expr pth)=
   picture pct; pair ctr;
   addto pct doublepath pth;
   ctr:=.5[llcorner pct, urcorner pct];
   pth shifted -ctr yscaled -1 shifted ctr

beginfig (0)
   path foo;
   foo:=halfcircle scaled 100;
   draw vflip (foo) withcolor red;
   draw foo withcolor green;

Laurent Méhats

More information about the metapost mailing list