summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/slideshow/pathalong.mp
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-11 22:58:36 +0000
committerKarl Berry <karl@freefriends.org>2006-01-11 22:58:36 +0000
commitac3c55a3216b5988f0e48ba9414ddb059f19a699 (patch)
treea752ab12de05a9ac4511903abc09675172018fd6 /Master/texmf-dist/metapost/slideshow/pathalong.mp
parentd087712418726a64822e40ce1c0627a514d17975 (diff)
trunk/Master/texmf-dist/metapost
git-svn-id: svn://tug.org/texlive/trunk@104 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/slideshow/pathalong.mp')
-rw-r--r--Master/texmf-dist/metapost/slideshow/pathalong.mp53
1 files changed, 53 insertions, 0 deletions
diff --git a/Master/texmf-dist/metapost/slideshow/pathalong.mp b/Master/texmf-dist/metapost/slideshow/pathalong.mp
new file mode 100644
index 00000000000..bc57cd6e262
--- /dev/null
+++ b/Master/texmf-dist/metapost/slideshow/pathalong.mp
@@ -0,0 +1,53 @@
+%% draw some text (t) along a curve (p)
+
+vardef pathalong (expr _p, t) =
+ save l, ll, del,let, pos, p;
+ picture let, ll;
+ path del, p;
+
+ l := length(t) - 1;
+ pos = 0;
+ p := _p;
+
+ ll := nullpicture;
+
+ for i := 0 upto l:
+
+ let := substring (i,i+1) of t infont defaultfont scaled defaultscale;
+
+ addto ll also (let rotated(angle(direction pos of p)))
+ shifted point pos of p;
+
+ del := (((xpart urcorner let, infinity)--(xpart urcorner let, -infinity))
+ rotated(angle(direction pos of p)))
+ shifted point pos of p;
+
+ p := subpath(pos,length(p)) of p;
+ pos := ypart (del intersectiontimes p);
+ exitif pos <= 0;
+
+ endfor;
+
+ ll
+enddef;
+
+%% draw the text contained in t so that the bottoms of the letters are on
+%% the base-line and the tops abut path p
+vardef textunder(expr p,t) =
+ save l, ll, pos, h, i;
+ picture l, ll;
+ numeric pos, h, i;
+ ll := nullpicture;
+ pos := 0;
+ for i = 0 upto (length t - 1):
+ l := substring(i, i+1) of t infont defaultfont scaled defaultscale;
+ h := ypart urcorner l;
+ if h > 0:
+ addto ll also (l yscaled ((ypart (((pos,-infinity)--(pos,infinity)) intersectionpoint p)) / ypart ulcorner l)) shifted (pos, 0);
+ fi;
+ pos := pos + xpart lrcorner l;
+ endfor;
+
+ ll
+enddef;
+