summaryrefslogtreecommitdiff
path: root/info/examples/lgc2/4-1-1.mp
blob: 38fecf31119bef652cfb4c921b33f3e1ad70f355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% --- start of displayed preamble in the book ---
vardef stxp(expr s,p)=
  save len,prefix,car,lab,xpos,cpos,ratio;
  numeric len[];
  string prefix,car;
  picture lab;
  len0=0;
  for i:=length s step -1 until 1:
    prefix:=substring(0,i) of s;
    lab:=thelabel(prefix,(0,0));
    len[i]=2*(xpart(urcorner lab));
  endfor;
  ratio=arclength(p)/len[length s];

  for i=0 upto (length s)-1:
    car:=substring(i,i+1) of s;
    if car<>" ":
      xpos:=((len[i]+len[i+1])/2)*ratio;
      cpos:=arctime xpos of p;
      lab:=thelabel(car,(0,0));
      draw lab rotated (angle (direction cpos of p))
               shifted (point cpos of p);
    fi;
  endfor;
enddef;
% --- end of displayed preamble in the book ---
% graphic converted to gray in book using 'color2gray'
defaultfont:="ptmr8r";
warningcheck:=0;
beginfig(1)
path p;
p=((0,0)..(4cm,7cm)..(5cm,3cm)..(3cm,2cm)) yscaled .5;
draw p withcolor red;
stxp("IN PRINCIPIO CREAVIT DEUS CÆLUM ET TERRAM.",p);
endfig;
end;