[metapost] More consistent and configurable label suffixes

Rasmus Villemoes burner+usenet at imf.au.dk
Mon Jul 30 12:49:02 CEST 2007


Hi

When labelling intersection points between curves, I often find that
the eight predefined directions are not quite sufficient; sometimes it
seems that the most appropriate place for the label is somewhere
between for instance .top and .urt. I use to solve this by tweaking
the curves a bit (when angles and/or lengths are not important) or
playing with labeloffset, or at worst calculating the center of the
label manually and using label() without a suffix. This
trial-and-error approach made me aware that the current suffix naming
is somewhat inconsistent; lft, bot, and top are 3 letters, whereas the
fourth "main" direction is abbreviated rt. It also takes quite a few
keystrokes to change bot to llft, and the relation between these
directions is rather obscure (one has to remember that directly below
is called "bottom", and abbreviated bot, whereas below and to the left
is called "the lower left corner", abbreviated llft). Consequently,
there is really no way of guessing the correct suffix for a given
direction except remembering all 8.

May I suggest that 16 new suffixes are introduced (along with the
current 8, to maintain backward compability), inspired by the
directions on a compass:

N   = north (equivalent to top)
NNE = north-northeast
NE  = northeast (e.t. urt)
ENE = east-northeast
E   = east (e.t. rt)
ESE = east-southeast
SE  = southeast (e.t. lrt)
SSE = south-southeast
S   = south (e.t. bot)
SSW = south-southwest
SW  = southwest (e.t. llft)
WSW = west-southwest
W   = west (e.t. lft)
WNW = west-northwest
NW  = northwest (e.t. ulft)
NNW = north-northwest

This, I think, would have a couple of advantages:

* Twice as many directions to choose from, making it more likely to
  find an appropriate position for the label without too much manual
  fiddling
* Abbreviations which are easier to remember, more consistent
  (main directions are one letter, those midway between are two letters,
  and the eight derived directions are three letters), and still
  rather natural. This also makes the code more readable.
* Fewer keystrokes to change from one suffix to a "nearby" one.


I don't currently remember if metapost is case-sensitive or not, but
if it is, one has to consider if only the (upper|lower)case versions
of these suffixes should be allowed, or both. The traditional
abbreviations are uppercase, but most (if not all) metapost internals
are lowercase.

According to http://en.wikipedia.org/wiki/Boxing_the_compass, there
are actually 16 more directions with traditional names, such as
northeast by east (NEbE), lying between NE ane ENE, but I don't think
these are quite as well-known as the above 16.

-- 
Rasmus Villemoes
<http://home.imf.au.dk/burner/>



More information about the metapost mailing list