thomas-holder.de

Therion Contributions

The following stuff is distributed under the GNU General Public License.

MetaPost Macros

I composed some MetaPost symbols in the style used by my club. See also the therion wiki.

Northarrow 1

def s_northarrow (expr rot) =
  begingroup
    interim defaultscale:=0.5; % scale your north arrow here
    T:=identity scaled defaultscale rotated -rot;
    pickup pencircle scaled (0.08cm * defaultscale);
    thdraw (-.4cm,-1.4cm)--(0,2.8cm)--(.4cm,-1.4cm)--cycle;
    p:=fullcircle scaled 1.6cm;
    thclean p; thdraw p;
    p:=(0.95cm,0)--(0.65cm,0);
    thdraw p; thdraw p xscaled -1;
    pickup pencircle scaled (0.12cm * defaultscale);
    p:=(0.28cm,0.42cm);
    thdraw p--(p yscaled -1)--(p xscaled -1)--(p scaled -1);
  endgroup;
enddef;

Northarrow 2

def s_northarrow (expr rot) =
  begingroup
    interim defaultscale:=0.7; % scale your north arrow here
    T:=identity scaled defaultscale rotated -rot;
    interim linecap:=squared;
    interim linejoin:=rounded;
    thfill (-.5cm,-.1cm)--(0,2.5cm)--(.5cm,-.1cm)--cycle;
    pickup pencircle scaled (0.08cm * defaultscale);
    thdraw (0,0)--(0,-2.5cm);
    pickup pencircle scaled (0.16cm * defaultscale);
    p:=(0.4cm,0.6cm);
    thdraw ((p--(p yscaled -1)--(p xscaled -1)--(p scaled -1)) shifted (0,-1.0cm));
    label.rt(thTEX("mg") scaled 1.6, (.6cm,-1.6cm)) transformed T;
  endgroup;
enddef;

Scalebar 1

def s_scalebar (expr l, units, txt) =
  begingroup
    interim warningcheck:=0;
    tmpl:=l / Scale * cm * units / 2;
    tmpx:=l / Scale * cm * units / 5;
    tmph:=5bp; % bar height
  endgroup;
  pickup PenC;
  draw (-tmpl,0)--(tmpl,0)--(tmpl,-tmph)--(-tmpl,-tmph)--cycle;
  p:=(0,0)--(tmpx,0)--(tmpx,-tmph)--(0,-tmph)--cycle;
  for i:=-2.5 step 2 until 2:
    fill p shifted (i * tmpx,0);
  endfor;
  begingroup
    interim labeloffset:=3.5bp;
    for i:=0 step (l/5) until (l-1):
      tmpx:=tmpl * (i * 2 / l - 1);
      label.top(thTEX(decimal (i)),(tmpx,0));
    endfor;
    label.top(thTEX(decimal (l) & "\thinspace" & txt),(tmpl,0));
    label.bot(thTEX("Originalmassstab = 1 : " & decimal round(Scale*100)),(0,-tmph));
  endgroup;
enddef;

Scalebar 2

def s_scalebar (expr l, units, txt) =
  begingroup
    interim warningcheck:=0;
    tmpl:=l / Scale * cm * units / 2;
    tmpx:=l / Scale * cm * units / 5;
    tmph:=5bp; % bar height
  endgroup;
  pickup PenC;
  draw (-tmpl,0)--(tmpl,0)--(tmpl,-tmph)--(-tmpl,-tmph)--cycle;
  p:=(0,0)--(tmpx,0)--(tmpx,-tmph)--(0,-tmph)--cycle;
  for i:=-2.5 step 2 until 2:
    fill p shifted (i * tmpx,0);
  endfor;
  begingroup
    interim labeloffset:=3.5bp;
    for i:=0 step (l/5) until (l-1):
      tmpx:=tmpl * (i * 2 / l - 1);
      label.bot(thTEX(decimal (i)),(tmpx,-tmph));
    endfor;
    label.bot(thTEX(decimal (l) & "\thinspace" & txt),(tmpl,-tmph));
    label.top(thTEX("Massstab 1 : " & decimal round(Scale*100)),(0,0));
  endgroup;
enddef;

Altitude Point

def p_altitude(expr pos)=
  T:=identity shifted pos;
  pickup PenD;
  p:=(-.3u,0)--(.3u,0);
  thdraw p; thdraw p rotated 90;
  p:=fullcircle scaled .2u;
  thclean p; thdraw p;
enddef;

vardef process_altitude@#(expr txt,pos) =
  thdrawoptions(withcolor .8red + .4blue);
  p_altitude(pos);
  % append "m" to label
  picture txtm;
  txtm:=image(
    draw txt;
    interim labeloffset:=0;
    label.urt(btex \thaltitude m etex, lrcorner txt);
  );
  % draw label
  interim labeloffset:=0.35u;
  lab:=thelabel@#(txtm, pos);
  draw lab _thop_; % use color
  thdrawoptions();
  bboxmargin:=0.8bp;
  write_circ_bbox((bbox lab) smoothed 2);
enddef;

vardef p_label@#(expr txt,pos,rot,mode) =
  if mode=1:
    process_altitude@#(txt,pos);
  else:
    if mode=7: interim labeloffset:=(u/8) fi;
    lab:=thelabel@#(txt, pos);
    if mode>1: pickup PenD fi;
    if mode=2: process_uplabel;
    elseif mode=3: process_downlabel;
    elseif mode=4: process_updownlabel;
    elseif mode=5: process_circledlabel;
    elseif mode=6: process_boxedlabel;
    elseif mode=7: process_label(pos,rot);  % station name
    elseif mode=8: process_filledlabel(pos, rot);
    else: process_label(pos,rot); fi;
  fi;
enddef;

Green colored continuous centerline

def l_survey_cave (expr p) =
  pickup PenC;
  draw p withcolor 0.5green;
enddef;

Hide small rocks

def l_rockborder (expr p) =
  if abs(llcorner p - urcorner p) > u:
    l_rockborder_UIS(p);
  fi;
enddef;

def l_rockedge (expr p) =
  if abs(llcorner p - urcorner p) > u:
    l_rockedge_UIS(p);
  fi;
enddef;

Floor Meander with "-attr width ..." attribute

def l_u_floormeander (expr P) =
  pair Pp; % moving point on middle line
  pair Pv; % normal vector on Pp
  pair PpX, PvX; % ... at i+0.5 (half next)
  path pB;  % border left
  path pBX; % border right

  % half width in meters (-attr width 1.0)
  if known(ATTR_width):
    whalf := 0.5 * scantokens(ATTR_width) * 1cm/Scale;
  else:
    whalf := 0.3u; % fallback for nice legend
  fi;

  T:=identity;
  cas := 0;
  dlzka := arclength P;
  mojkrok:=adjust_step(dlzka, 0.25u);
  forever:
    t := arctime cas of P;
    t2 := arctime (cas + mojkrok/2) of P;
    Pp := (point t of P);
    PpX := (point t2 of P);
    Pv := unitvector(thdir(P,t)) rotated 90;
    PvX := unitvector(thdir(P,t2)) rotated 90;
    % draw ticks only if tick-length < 3/4*width
    if whalf*3/2 > 0.2u:
      pickup PenD;
      thdraw (Pp + (whalf - 0.2u) * Pv) -- (Pp + whalf * Pv);
      thdraw (PpX - (whalf - 0.2u) * PvX) -- (PpX - whalf * PvX);
    fi;
    % border
    if cas > 0:
      pB := pB -- (Pp + whalf * Pv);
      pBX := pBX -- (PpX - whalf * PvX);
    else:
      pB := (Pp + whalf * Pv);
      pBX := (PpX - whalf * PvX);
    fi;
    % increment position
    cas := cas + mojkrok;
    exitif cas > dlzka;
  endfor;
  pickup PenC;
  thdraw pB;
  thdraw pBX;
enddef;