summaryrefslogtreecommitdiff
path: root/systems/doc/metapost/source-tutorial/label.mp
blob: da0afcbf899dfe0839045138f7bb7b000c3b497b (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
prologues:=3;

if scantokens(mpversion) > 1.005:
  outputtemplate :=
else:
  filenametemplate
fi
"%j-%c.mps";

verbatimtex
%&latex
\documentclass[11pt]{article}
\usepackage[charter]{mathdesign}
\usepackage[T1]{fontenc}
\renewcommand*{\ttdefault}{lmtt}
\begin{document}
etex

% Determine the size of the default font
w:=fontsize defaultfont;

beginfig(1);
	% Place a "point" at (0,0)
	fill fullcircle scaled 3;

	% Draw a square around the point
	draw (-7*w/16,-7*w/16)--(7*w/16,-7*w/16)--(7*w/16,7*w/16)--(-7*w/16,7*w/16)--cycle;

	% Draw vertical and horizontal lines through the point
	draw (0,-7*w/16)--(0,7*w/16);
	draw (-7*w/16,0)--(7*w/16,0);

	% Label the 4 positions
	label.lft(btex \texttt{lft} etex,(-w/4,0));
	label.rt(btex \texttt{rt} etex,(w/4,0));
	label.bot(btex \texttt{bot} etex,(0,-w/4));
	label.top(btex \texttt{top} etex,(0,w/4));

	% Manually set the bbox
	setbounds currentpicture to (-2*w,-2*w)--(2*w,-2*w)--(2*w,2*w)--(-2*w,2*w)--cycle;
endfig;

beginfig(2);
	% Place a "point" at (0,0)
	fill fullcircle scaled 3;

	% Draw a square around the point
	draw (-7*w/16,-7*w/16)--(7*w/16,-7*w/16)--(7*w/16,7*w/16)--(-7*w/16,7*w/16)--cycle;

	% Draw diagonals of the square through the point
	draw (-7*w/16,-7*w/16)--(7*w/16,7*w/16);
	draw (-7*w/16,7*w/16)--(7*w/16,-7*w/16);

	% Label the 4 positions
	label.llft(btex \texttt{llft} etex,(-w/4,-w/4));
	label.ulft(btex \texttt{ulft} etex,(-w/4,w/4));
	label.lrt(btex \texttt{lrt} etex,(w/4,-w/4));
	label.urt(btex \texttt{urt} etex,(w/4,w/4));

	% Manually set the bbox
	setbounds currentpicture to (-11/4*w,-2*w)--(11/4*w,-2*w)--(11/4*w,2*w)--(-11/4*w,2*w)--cycle;
endfig;
end