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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
|
% \iffalse
% +AMDG This document was begun on 1E June 11EE, the vigil
% of the Nativity of St. John the Baptist, and it is humbly
% dedicated to him and to the Immaculate Heart of Mary, for
% their prayers, and to the Sacred Heart of Jesus, for His
% mercy.
%
% This document is copyright 2015 by Donald P. Goodman, and is
% released publicly under the LaTeX Project Public License. The
% distribution and modification of this work is constrained by the
% conditions of that license. See
% http://www.latex-project.org/lppl.txt
% for the text of the license. This document is released
% under version 1.3 of that license, and this work may be distributed
% or modified under the terms of that license or, at your option, any
% later version.
%
% This work has the LPPL maintenance status 'maintained'.
%
% The Current Maintainer of this work is Donald P. Goodman
% (dgoodmaniii@gmail.com).
%
% This work consists of the files roundrect.dtx and
% roundrect.ins, along with the generated file roundrect.mp
% and roundrect.pdf, and the README.
% \fi
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage{docmfp}
\usepackage{url}
\usepackage[typeone]{dozenal}
\usepackage{verbatim}
\usepackage{mflogo}
\usepackage[everymp={input roundrect;},latex]{gmp}
\usepackage{makeidx}
\makeindex
\long\def\demonstrate#1#2{%
\bigskip%
\hrule%
\hbox to\linewidth{%
\hbox to0.5\linewidth{%
\vbox to2in{\vfil#1\vfil}%
}\hbox to0.5\linewidth{%
\vbox to2in{\vfil#2\vfil}%
}%
}%
\hrule%
\bigskip%
}
\begin{document}
\DocInput{roundrect.dtx}
\end{document}
%</driver>
% \fi
% \title{The \texttt{roundrect} Macros, v2.1}
% \author{Donald P.\ Goodman III}
% \date{\today}
%
% \maketitle
% \begin{abstract}\noindent
% The |roundrect| macros for \MP\ provide extremely
% configurable, extremely versatile rectangles (including
% rounded corners), intended primarily for inclusion in
% documents produced by \TeX\ and friends. The idea was to
% provide a \MP-based replacement for the incredibly
% versatile |tcolorbox| package; the macros are far from
% achieving that goal. But they are nevertheless extremely
% useful.
% \end{abstract}
%
% \tableofcontents
%
% \section{Introduction}
%
% While Ti\textit{k}Z and its many accompanying packages,
% particularly |tcolorbox|, are wonderful and powerful
% tools, whenever using them I inevitably feel completely
% lost, and I exert great effort doing comparatively simple
% things. Contrariwise, thanks to my experience with the
% |drm| and |dozenal| packages, writing in \MP\ is quite
% straightforward for me. So I decided to try to write some
% generalized macros to provide functionality similar to
% that of |tcolorbox|. It's not even close to that kind of
% flexibility or power, but it's still quite useful and
% versatile, so I make it available for anyone who might be
% interested.
%
% This document was typeset in accordance with the
% |docstrip| utility, which allows the automatic extraction
% of code and documentation from the same document.
%
% \section{Prerequisites and Conventions}
%
% Some prerequesites for using this package are \MP\ itself
% (obviously). If you're using the package with \LaTeX, the
% |gmp| package would probably be helpful; be sure to use
% the |latex| package option. Finally, the
% package internally calls |TEX.mp|, so that is also
% required. All of these should be packaged in any
% reasonably modern \LaTeX\ system, such as \TeX Live or
% Mik\TeX.
%
% This documentation assumes nothing about your personal
% \TeX\ or \MP\ environment. Con\TeX t and the various
% forms of Lua\TeX\ have \MP\ built-in; with pdf\LaTeX, the
% author's choice, one can use the |gmp| package to
% include the source directly in one's document (that's
% what's been done in this documentation) or develop a
% simple script to compile them afterwards and include them
% in the source via |\includegraphics| (probably the
% quickest option, since compilation is done in advance).
% Here, we simply post the plain vanilla \MP\ code, and let
% you work out those details however you prefer.
%
% \section{Shapes and Styles}
%
% The core of all the action is the
% \DescribeMacro{roundrect}|roundrect| macro; this
% will set up your rounded rectangle in the plainest
% way possible. The first argument is the box's height, the
% second its width, and the third its name, by which you
% will draw it later:
%
% \demonstrate{%
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }%
%
% All the corners don't \emph{have} to be rounded; we can
% make them square if we want. To do things like this, we
% use the macro
% \DescribeMacro{rrborderrad()}|rrborderrad()|, which takes
% a single argument giving the border radius we want; that
% is, how rounded we want the corners of our rectangle.
% Higher values will be more rounded, lower values will be
% less:
%
% \demonstrate{%
% \hbox{|rrborderrad(10pt);|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrborderrad(10pt);
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }%
%
% Notice that the corners in this, with |rrborderrad()| set
% to |10pt|, are much less rounded than the previous
% example. The default border radius is |40pt|, which is
% quite rounded.
%
% |rrborderrad()| provides an easy way to set the border
% radius of all four corners at once; however, we can also
% control each corner individually, with
% \DescribeMacro{rrtoplftborderrad}|rrtoplftborderrad|,
% \DescribeMacro{rrbotlftborderrad}|rrbotlftborderrad|,
% \DescribeMacro{rrtoprtborderrad}|rrtoprtborderrad|, and
% \DescribeMacro{rrbotrtborderrad}|rrbotrtborderrad|, which
% are parameters rather than macros; that is, we define them
% using |:=| rather than as an argument in parentheses:
%
% \demonstrate{%
% \hbox{|rrtoplftborderrad := 20pt;|}
% \hbox{|rrbotlftborderrad := 40pt;|}
% \hbox{|rrtoprtborderrad := 10pt;|}
% \hbox{|rrbotrtborderrad := 60pt;|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrtoplftborderrad := 20pt;
% rrbotlftborderrad := 40pt;
% rrtoprtborderrad := 10pt;
% rrbotrtborderrad := 60pt;
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }%
%
% As you can see, this makes it possible to create a large
% variety of shapes, including the ability to arbitrarily
% flatten any side of the rectangle desired just by setting
% the border radius of the appropriate corners to |0pt|:
%
% \demonstrate{%
% \hbox{|rrtoplftborderrad := 0pt;|}
% \hbox{|rrtoprtborderrad := 0pt;|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrtoplftborderrad := 0pt;
% rrtoprtborderrad := 0pt;
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }%
%
% Here, we've flattened the top border by setting the top
% right and top left corners' border radii to |0pt|.
% This ability to flatten any given side of the rectangle
% makes it much easier to combine multiple rectangles into
% interesting forms, which we'll see a bit more about later.
%
% \section{Coloring the Parts}
% \label{sect:colorpart}
%
% The colors of the |roundrect| are extremely configurable,
% both on the whole and for individual parts. The
% background color of the |roundrect| is controlled by
% \DescribeMacro{rrinnercolor}|rrinnercolor|, while the
% border is colored by
% \DescribeMacro{rrbordercolor}|rrbordercolor()|.
%
% \demonstrate{%
% \hbox{|rrbordercolor(blue);|}
% \hbox{|rrinnercolor := red;|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrbordercolor(blue);
% rrinnercolor := red;
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }%
%
% By default, |rrinnercolor| is white and |rrbordercolor| is
% black. Notice that |rrbordercolor| is a \emph{macro}, not
% a parameter; that's because each border can be
% individually colored, and this macro simply does all of
% them at once. We'll see more about that later.
%
% You can also completely suppress the border by using
% \DescribeMacro{rrnotop}|rrnotop|,
% \DescribeMacro{rrnobot}|rrnobot|,
% \DescribeMacro{rrnolft}|rrnolft|, and
% \DescribeMacro{rrnort}|rrnort|, which is particularly
% useful when you want to combine multiple rectangles
% without making an obvious border between them. You can
% combine these in any way you like:
%
% \demonstrate{%
% \hbox{|rrbordercolor(blue);|}
% \hbox{|rrinnercolor := red;|}
% \hbox{|rrnotop := true;|}
% \hbox{|rrnobot := true;|}
% \hbox{|rrborderrad(0pt);|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrbordercolor(blue);
% rrinnercolor := red;
% rrnotop := true;
% rrnobot := true;
% rrborderrad(0pt);
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }%
%
% Here we've squared all the corners to make it easier to
% see what's going on.
%
% Each border can be colored individually and separately
% from the others, using the commands you'd expect:
%
% \demonstrate{%
% \hbox{|rrtopbordercolor := blue;|}
% \hbox{|rrbotbordercolor := green;|}
% \hbox{|rrlftbordercolor := red;|}
% \hbox{|rrrtbordercolor := black;|}
% \hbox{|rrborderrad(20pt);|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrtopbordercolor := blue;
% rrbotbordercolor := green;
% rrlftbordercolor := red;
% rrrtbordercolor := black;
% rrborderrad(20pt);
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }%
%
% There is obviously some difficulty in determining what
% part of each rounded corner should be colored how; this
% ability is typically more useful with a single, flattened
% side, to help it blend in better when combined with other
% constructs:
%
% \demonstrate{%
% \hbox{|rrbordercolor(black);|}
% \hbox{|rrbotbordercolor := green;|}
% \hbox{|rrinnercolor := red;|}
% \hbox{|rrborderrad(20pt);|}
% \hbox{|rrbotlftborderrad := 0pt;|}
% \hbox{|rrbotrtborderrad := 0pt;|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrbordercolor(black);
% rrbotbordercolor := green;
% rrinnercolor := red;
% rrborderrad(20pt);
% rrbotlftborderrad := 0pt;
% rrbotrtborderrad := 0pt;
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }
%
% Perhaps you don't like the border; you'd like it thicker,
% or drawn with a square rather than a circular pen. You're
% in luck; \DescribeMacro{rrborderpen()}|rrborderpen()|
% takes the single argument of the pen you'd like to draw
% the border with, defined like any other \MP\ pen:
%
% \demonstrate{%
% \hbox{|rrborderpen(pensquare scaled 3);|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrborderpen(pensquare scaled 3);
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }
%
% The default border pen is |pencircle scaled 1.5|, so this
% results in a square pen rather than a circular one, twice
% as thick. You can also use individual pens for each
% border, as expected:
%
% \demonstrate{%
% \hbox{|rrbotlftborderrad := 0pt;|}
% \hbox{|rrbotrtborderrad := 0pt;|}
% \hbox{|rrbotbordercolor := green;|}
% \hbox{|rrbotborderpen := pensquare yscaled 6;|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrbotlftborderrad := 0pt;
% rrbotrtborderrad := 0pt;
% rrbotbordercolor := green;
% rrbotborderpen := pensquare yscaled 6;
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }
%
% Here we've flattened the bottom border, colored it green,
% and drawn it with a square pen scaled on the y-axis only
% by 6. Clearly, there are huge possibilities here.
%
% \section{Drop Shadows}
% \label{sect:dropshadows}
%
% We can also put a \emph{shadow} on the boxes using
% \DescribeMacro{rrdropshadow}|rrdropshadow|, a boolean
% value which defaults to |false|:
%
% \demonstrate{%
% \hbox{|rrdropshadow := true;|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrdropshadow := true;
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }%
%
% The drop shadow always mimics the shape of the box itself;
% there is presently no way to avoid that. If for some
% reason you want to, you'll have to create a separate
% |roundrect| and place it manually.
%
% We can control the size and direction of the drop shadow
% fairly easily, however, along with its color. Its color
% is controlled by
% \DescribeMacro{rrshadowcolor}|rrshadowcolor|, which
% can be set to any arbitrary \MP\ color:
%
% \demonstrate{%
% \hbox{|rrdropshadow := true;|}
% \hbox{|rrshadowcolor := blue;|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrdropshadow := true;
% rrshadowcolor := blue;
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }%
%
% The position of the drop shadow is governed by
% \DescribeMacro{rrshadowx}|rrshadowx| and
% \DescribeMacro{rrshadowy}|rrshadowy|, which will shift the
% |roundrect| on the |x| or |y| axis, respectively. By
% default, these are set to one quarter of the border radius
% in effect for the bottom left corner:
%
% \demonstrate{%
% \hbox{|rrdropshadow := true;|}
% \hbox{|rrshadowcolor := blue;|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrdropshadow := true;
% rrshadowcolor := blue;
% rrshadowx := -rrbotlftborderrad/4;
% rrshadowy := rrbotlftborderrad/4;
% roundrect(1in,2in)(rectangle);
% draw rectangle shifted (1in,0.5in);
% \end{mpost}
% }%
%
% \section{Including Text}
% \label{sect:text}
%
% Finally, we can put text in the rectangles; this is as
% configurable as everything else:
%
% \demonstrate{%
% \hbox{|rrbodytext := "Let's put some text into this rectangle and see if it typesets correctly!";|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrbodytext := "Let's put some text into this rectangle and see if it typesets correctly!";
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }
%
% The font and style of the text can be controlled with
% \DescribeMacro{rrtextfont}|rrtextfont|, and the color of
% the text can be controlled with
% \DescribeMacro{rrtextcolor}|rrtextcolor|:
%
% \demonstrate{%
% \hbox{|rrbodytext := "Text in a label";|}
% \hbox{|rrtextcolor := green;|}
% \hbox{|rrtextalign := "$\backslash$raggedleft";|}
% \hbox{|rrtextfont := "$\backslash$fontsize{17pt}{19pt}$\backslash$ selectfont$\backslash$ itshape";|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrbodytext := "Text in a label";
% rrtextcolor := green;
% rrtextalign := "\unexpanded{\raggedleft}";
% rrtextfont := "\unexpanded{\fontsize{17pt}{19pt}\selectfont\itshape"};
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }
%
% We also used, without explaining it first,
% \DescribeMacro{rrtextalign}|rrtextalign|, which allows
% insertion of text alignment commands. This can also be
% inserted in the |rrtextfont| variable, but it seemed
% logical to have a separate parameter for it. It's default
% is |\centering|.
%
% The width of the text is governed by
% \DescribeMacro{rrtextwd}|rrtextwd|, which defaults to the
% same width as the rectangle with a |3pt| buffer on either
% side. The buffer is not directly controllable, but the
% width can be set however you like:
%
% \demonstrate{%
% \hbox{|rrbodytext := "Let's put some text into this rectangle and see if it typesets correctly!";|}
% \hbox{|rrtextwd := 80pt;|}
% \hbox{|roundrect(1in,2in)(rectangle);|}
% \hbox{|draw rectangle;|}
% }{%
% \begin{mpost}
% rrbodytext := "Let's put some text into this rectangle and see if it typesets correctly!";
% rrtextwd := 80pt;
% roundrect(1in,2in)(rectangle);
% draw rectangle;
% \end{mpost}
% }
%
%
% Finally, to restore all these values to the default, use
% the |rrrestorevals;| directive. This will clear
% everything to default so you can have a completely
% different |roundrect| in the same figure.
%
% \section{Implementation}
%
% \begin{macrocode}
input TEX;
color rrinnercolor; rrinnercolor := white;
numeric rrtoprtborderrad; rrtoprtborderrad := 40pt;
numeric rrbotrtborderrad; rrbotrtborderrad := 40pt;
numeric rrbotlftborderrad; rrbotlftborderrad := 40pt;
numeric rrtoplftborderrad; rrtoplftborderrad := 40pt;
numeric rrtextwd; rrtextwd := 0;
numeric rrshadowx; rrshadowx := rrbotrtborderrad/4;
numeric rrshadowy; rrshadowy := -rrbotrtborderrad/4;
string rrtextfont; rrtextfont := "\fontsize{10pt}{12pt}\selectfont ";
color rrtextcolor; rrtextcolor := black;
string rrbodytext; rrbodytext := "";
string rrtextalign; rrtextalign := "\centering";
boolean rrnotop; rrnotop := false;
boolean rrnobot; rrnobot := false;
boolean rrnolft; rrnolft := false;
boolean rrnort; rrnort := false;
boolean rrdropshadow; rrdropshadow := false;
color rrtopbordercolor; rrtopbordercolor := black;
color rrbotbordercolor; rrbotbordercolor := black;
color rrlftbordercolor; rrlftbordercolor := black;
color rrrtbordercolor; rrrtbordercolor := black;
color rrshadowcolor; rrshadowcolor := black;
def rrbordercolor(expr x) =
rrtopbordercolor := x;
rrbotbordercolor := x;
rrlftbordercolor := x;
rrrtbordercolor := x;
enddef;
def rrborderrad(expr x) =
rrtoplftborderrad := x;
rrbotlftborderrad := x;
rrtoprtborderrad := x;
rrbotrtborderrad := x;
enddef;
pen rrtopborderpen; rrtopborderpen := pencircle scaled 1.5;
pen rrbotborderpen; rrbotborderpen := pencircle scaled 1.5;
pen rrlftborderpen; rrlftborderpen := pencircle scaled 1.5;
pen rrrtborderpen; rrrtborderpen := pencircle scaled 1.5;
def rrborderpen(expr x) =
rrtopborderpen := x;
rrbotborderpen := x;
rrlftborderpen := x;
rrrtborderpen := x;
enddef;
def rrrestorevals =
rrborderrad(40pt);
rrbordercolor(black);
rrborderpen(pencircle scaled 1.5);
rrinnercolor := white;
rrnotop := false;
rrnobot := false;
rrnolft := false;
rrnort := false;
rrtextwd := 0;
rrtextfont := "\fontsize{10pt}{12pt}\selectfont ";
rrtextcolor := black;
rrbodytext := "";
rrtextalign; rrtextalign := "\centering";
rrdropshadow := false;
rrshadowcolor := black;
rrshadowx := rrbotrtborderrad/4;
rrshadowy := -rrbotrtborderrad/4;
enddef;
def roundrect(expr rrht, rrwd)(suffix name) =
TEXPRE("%&latex" & char(10) & "\documentclass{article}\begin{document}");
TEXPOST("\end{document}");
if (rrtextwd = 0):
rrtextwd := rrwd - 12pt;
fi
path rra; path rrb; path rrc; path rrd;
pair a; pair b; pair c; pair d;
a := (0,0) shifted (-rrwd/2,-rrht/2);
b := (0,0) shifted (rrwd/2,-rrht/2);
c := (0,0) shifted (rrwd/2,rrht/2);
d := (0,0) shifted (-rrwd/2,rrht/2);
rra := fullcircle scaled rrbotlftborderrad shifted (xpart a +
(rrbotlftborderrad/2),ypart a + (rrbotlftborderrad/2));
rrb := fullcircle scaled rrbotrtborderrad shifted (xpart b -
(rrbotrtborderrad/2),ypart b + (rrbotrtborderrad/2));
rrd := fullcircle scaled rrtoplftborderrad shifted (xpart d +
(rrtoplftborderrad/2),ypart d - (rrtoplftborderrad/2));
rrc := fullcircle scaled rrtoprtborderrad shifted (xpart c -
(rrtoprtborderrad/2),ypart c - (rrtoprtborderrad/2));
pair f; f := (a--b) intersectionpoint rra;
pair g; g := (a--b) intersectionpoint rrb;
pair h; h := (b--c) intersectionpoint rrb;
pair i; i := (b--c) intersectionpoint rrc;
pair j; j := (c--d) intersectionpoint rrc;
pair k; k := (c--d) intersectionpoint rrd;
pair l; l := (d--a) intersectionpoint rrd;
pair m; m := (d--a) intersectionpoint rra;
picture name;
picture border;
picture rrtext;
pair n; pair o;
path rrtoplftcorner; path rrbotlftcorner;
path rrtoprtcorner; path rrbotrtcorner;
path rrtopborder; path rrbotborder;
path rrlftborder; path rrrtborder;
rrtoplftcorner := l{up}..{right}k;
rrtoprtcorner := j{right}..{down}i;
rrbotrtcorner := h{down}..{left}g;
rrbotlftcorner := f{left}..{up}m;
rrtopborder := rrtoplftcorner--rrtoprtcorner;
rrbotborder := rrbotrtcorner--rrbotlftcorner;
rrlftborder := rrbotlftcorner--rrtoplftcorner;
rrrtborder := rrtoprtcorner--rrbotrtcorner;
picture rrdropshadowpic;
if (rrdropshadow = true):
rrdropshadowpic := image(fill rrtoplftcorner--rrtoprtcorner--
rrbotrtcorner--rrbotlftcorner--cycle
shifted (rrshadowx,rrshadowy) withcolor
rrshadowcolor);
else:
rrdropshadowpic := currentpicture;
fi
name := currentpicture;
addto name also rrdropshadowpic;
rrdropshadowpic := image(fill rrtoplftcorner--rrtoprtcorner--
rrbotrtcorner--rrbotlftcorner--cycle withcolor
rrinnercolor);
addto name also rrdropshadowpic;
% name := image(fill rrtoplftcorner--rrtoprtcorner--
% rrbotrtcorner--rrbotlftcorner--cycle withcolor
% rrinnercolor);
picture rrtmpborder;
border := currentpicture;
if (rrnotop = false):
rrtmpborder := image(draw rrtopborder withcolor
rrtopbordercolor withpen rrtopborderpen);
addto border also rrtmpborder;
fi
if (rrnobot = false):
rrtmpborder := image(draw rrbotborder withcolor
rrbotbordercolor withpen rrbotborderpen);
addto border also rrtmpborder;
fi
if (rrnolft = false):
rrtmpborder := image(draw rrlftborder withcolor
rrlftbordercolor withpen rrlftborderpen);
addto border also rrtmpborder;
fi
if (rrnort = false):
rrtmpborder := image(draw rrrtborder withcolor
rrrtbordercolor withpen rrrtborderpen);
addto border also rrtmpborder;
fi
addto name also border;
rrtext :=
image(label(TEX("\parbox{"&decimal(rrtextwd)&"bp}{"&rrtextalign&rrtextfont&" "&rrbodytext&"}"),(0,0)) withcolor rrtextcolor;);
addto name also rrtext;
enddef;
% \end{macrocode}
|