Debian Codegraph @

texmf-dist/metapost/base/rboxes.mp

raw
1 % $Id: rboxes.mp,v 1.2 2004/09/19 21:47:11 karl Exp $
2 % Public domain.
3
4 % This macro package is exactly like boxes.mp except that it defines
5 % an additional macro rboxit<box name>(<string or picture>) that produces
6 % rectangular boxes with rounded corners.
7
8 \input boxes
9
10
11
12
13 % Rectangular boxes with rounded corners
14
15 newinternal rbox_radius;
16 rbox_radius := 8bp;
17
18 vardef rboxit@#(text tt) =
19 beginbox_("rboxpath_","sizebox_",@#,tt);
20 generic_declare(pair) _n.sw, _n.s, _n.se, _n.e, _n.ne, _n.n, _n.nw, _n.w;
21 0 = xpart (@#nw-@#sw) = ypart(@#se-@#sw);
22 0 = xpart(@#ne-@#se) = ypart(@#ne-@#nw);
23 @#w = .5[@#nw,@#sw];
24 @#s = .5[@#sw,@#se];
25 @#e = .5[@#ne,@#se];
26 @#n = .5[@#ne,@#nw];
27 @#ne-@#c = @#c-@#sw = (@#dx,@#dy) + .5*(urcorner pic_@# - llcorner pic_@#);
28 endbox_(clearb_,@#);
29 enddef;
30
31 def rboxpath_(suffix $) =
32 save _r;
33 _r = min(rbox_radius, .5*ypart($.n-$.s), .5*xpart($.e-$.w));
34 $.sw+(_r,0) {right}..{right} $.se-(_r,0)
35 ..$.se+(0,_r) {up}..{up} $.ne-(0,_r)
36 ..$.ne-(_r,0) {left}..{left} $.nw+(_r,0)
37 ..$.nw-(0,_r) {down}..{down} $.sw+(0,_r) .. cycle
38 enddef;
39
40
41 % sizebox_ and clearb_ are defined in boxes.mp