| 1 |
%% |
| 2 |
%% This is file `roundrect.mp', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% roundrect.dtx (with options: `package') |
| 8 |
%% This is a generated file. |
| 9 |
%% |
| 10 |
%% This document is copyright 2015 by Donald P. Goodman, and is |
| 11 |
%% released publicly under the LaTeX Project Public License. The |
| 12 |
%% distribution and modification of this work is constrained by the |
| 13 |
%% conditions of that license. See |
| 14 |
%% http://www.latex-project.org/lppl.txt |
| 15 |
%% for the text of the license. This document is released |
| 16 |
%% under version 1.3 of that license, and this work may be distributed |
| 17 |
%% or modified under the terms of that license or, at your option, any |
| 18 |
%% later version. |
| 19 |
%% |
| 20 |
%% This work has the LPPL maintenance status 'maintained'. |
| 21 |
%% |
| 22 |
%% The Current Maintainer of this work is Donald P. Goodman |
| 23 |
%% ([email protected]). |
| 24 |
%% |
| 25 |
%% This work consists of the files roundrect.dtx and |
| 26 |
%% roundrect.ins, along with the generated file roundrect.mp |
| 27 |
%% and roundrect.pdf, and the README. |
| 28 |
|
| 29 |
input TEX; |
| 30 |
color rrinnercolor; rrinnercolor := white; |
| 31 |
numeric rrtoprtborderrad; rrtoprtborderrad := 40pt; |
| 32 |
numeric rrbotrtborderrad; rrbotrtborderrad := 40pt; |
| 33 |
numeric rrbotlftborderrad; rrbotlftborderrad := 40pt; |
| 34 |
numeric rrtoplftborderrad; rrtoplftborderrad := 40pt; |
| 35 |
numeric rrtextwd; rrtextwd := 0; |
| 36 |
numeric rrshadowx; rrshadowx := rrbotrtborderrad/4; |
| 37 |
numeric rrshadowy; rrshadowy := -rrbotrtborderrad/4; |
| 38 |
string rrtextfont; rrtextfont := "\fontsize{10pt}{12pt}\selectfont "; |
| 39 |
color rrtextcolor; rrtextcolor := black; |
| 40 |
string rrbodytext; rrbodytext := ""; |
| 41 |
string rrtextalign; rrtextalign := "\centering"; |
| 42 |
string rrusepackage; rrusepackage := ""; |
| 43 |
boolean rrnotop; rrnotop := false; |
| 44 |
boolean rrnobot; rrnobot := false; |
| 45 |
boolean rrnolft; rrnolft := false; |
| 46 |
boolean rrnort; rrnort := false; |
| 47 |
boolean rrdropshadow; rrdropshadow := false; |
| 48 |
color rrtopbordercolor; rrtopbordercolor := black; |
| 49 |
color rrbotbordercolor; rrbotbordercolor := black; |
| 50 |
color rrlftbordercolor; rrlftbordercolor := black; |
| 51 |
color rrrtbordercolor; rrrtbordercolor := black; |
| 52 |
color rrshadowcolor; rrshadowcolor := black; |
| 53 |
def rrbordercolor(expr x) = |
| 54 |
rrtopbordercolor := x; |
| 55 |
rrbotbordercolor := x; |
| 56 |
rrlftbordercolor := x; |
| 57 |
rrrtbordercolor := x; |
| 58 |
enddef; |
| 59 |
def rrborderrad(expr x) = |
| 60 |
rrtoplftborderrad := x; |
| 61 |
rrbotlftborderrad := x; |
| 62 |
rrtoprtborderrad := x; |
| 63 |
rrbotrtborderrad := x; |
| 64 |
enddef; |
| 65 |
pen rrtopborderpen; rrtopborderpen := pencircle scaled 1.5; |
| 66 |
pen rrbotborderpen; rrbotborderpen := pencircle scaled 1.5; |
| 67 |
pen rrlftborderpen; rrlftborderpen := pencircle scaled 1.5; |
| 68 |
pen rrrtborderpen; rrrtborderpen := pencircle scaled 1.5; |
| 69 |
def rrborderpen(expr x) = |
| 70 |
rrtopborderpen := x; |
| 71 |
rrbotborderpen := x; |
| 72 |
rrlftborderpen := x; |
| 73 |
rrrtborderpen := x; |
| 74 |
enddef; |
| 75 |
def rrrestorevals = |
| 76 |
rrborderrad(40pt); |
| 77 |
rrbordercolor(black); |
| 78 |
rrborderpen(pencircle scaled 1.5); |
| 79 |
rrinnercolor := white; |
| 80 |
rrnotop := false; |
| 81 |
rrnobot := false; |
| 82 |
rrnolft := false; |
| 83 |
rrnort := false; |
| 84 |
rrtextwd := 0; |
| 85 |
rrtextfont := "\fontsize{10pt}{12pt}\selectfont "; |
| 86 |
rrtextcolor := black; |
| 87 |
rrbodytext := ""; |
| 88 |
rrtextalign; rrtextalign := "\centering"; |
| 89 |
rrdropshadow := false; |
| 90 |
rrshadowcolor := black; |
| 91 |
rrshadowx := rrbotrtborderrad/4; |
| 92 |
rrshadowy := -rrbotrtborderrad/4; |
| 93 |
enddef; |
| 94 |
def roundrect(expr rrht, rrwd)(suffix name) = |
| 95 |
TEXPRE("%&latex" & char(10) & "\documentclass{article}" & rrusepackage & "\begin{document}"); |
| 96 |
TEXPOST("\end{document}"); |
| 97 |
if (rrtextwd = 0): |
| 98 |
rrtextwd := rrwd - 12pt; |
| 99 |
fi |
| 100 |
path rra; path rrb; path rrc; path rrd; |
| 101 |
pair a; pair b; pair c; pair d; |
| 102 |
a := (0,0) shifted (-rrwd/2,-rrht/2); |
| 103 |
b := (0,0) shifted (rrwd/2,-rrht/2); |
| 104 |
c := (0,0) shifted (rrwd/2,rrht/2); |
| 105 |
d := (0,0) shifted (-rrwd/2,rrht/2); |
| 106 |
rra := fullcircle scaled rrbotlftborderrad shifted (xpart a + |
| 107 |
(rrbotlftborderrad/2),ypart a + (rrbotlftborderrad/2)); |
| 108 |
rrb := fullcircle scaled rrbotrtborderrad shifted (xpart b - |
| 109 |
(rrbotrtborderrad/2),ypart b + (rrbotrtborderrad/2)); |
| 110 |
rrd := fullcircle scaled rrtoplftborderrad shifted (xpart d + |
| 111 |
(rrtoplftborderrad/2),ypart d - (rrtoplftborderrad/2)); |
| 112 |
rrc := fullcircle scaled rrtoprtborderrad shifted (xpart c - |
| 113 |
(rrtoprtborderrad/2),ypart c - (rrtoprtborderrad/2)); |
| 114 |
pair f; f := (a--b) intersectionpoint rra; |
| 115 |
pair g; g := (a--b) intersectionpoint rrb; |
| 116 |
pair h; h := (b--c) intersectionpoint rrb; |
| 117 |
pair i; i := (b--c) intersectionpoint rrc; |
| 118 |
pair j; j := (c--d) intersectionpoint rrc; |
| 119 |
pair k; k := (c--d) intersectionpoint rrd; |
| 120 |
pair l; l := (d--a) intersectionpoint rrd; |
| 121 |
pair m; m := (d--a) intersectionpoint rra; |
| 122 |
picture name; |
| 123 |
picture border; |
| 124 |
picture rrtext; |
| 125 |
pair n; pair o; |
| 126 |
path rrtoplftcorner; path rrbotlftcorner; |
| 127 |
path rrtoprtcorner; path rrbotrtcorner; |
| 128 |
path rrtopborder; path rrbotborder; |
| 129 |
path rrlftborder; path rrrtborder; |
| 130 |
rrtoplftcorner := l{up}..{right}k; |
| 131 |
rrtoprtcorner := j{right}..{down}i; |
| 132 |
rrbotrtcorner := h{down}..{left}g; |
| 133 |
rrbotlftcorner := f{left}..{up}m; |
| 134 |
rrtopborder := rrtoplftcorner--rrtoprtcorner; |
| 135 |
rrbotborder := rrbotrtcorner--rrbotlftcorner; |
| 136 |
rrlftborder := rrbotlftcorner--rrtoplftcorner; |
| 137 |
rrrtborder := rrtoprtcorner--rrbotrtcorner; |
| 138 |
picture rrdropshadowpic; |
| 139 |
if (rrdropshadow = true): |
| 140 |
rrdropshadowpic := image(fill rrtoplftcorner--rrtoprtcorner-- |
| 141 |
rrbotrtcorner--rrbotlftcorner--cycle |
| 142 |
shifted (rrshadowx,rrshadowy) withcolor |
| 143 |
rrshadowcolor); |
| 144 |
else: |
| 145 |
rrdropshadowpic := currentpicture; |
| 146 |
fi |
| 147 |
name := currentpicture; |
| 148 |
addto name also rrdropshadowpic; |
| 149 |
rrdropshadowpic := image(fill rrtoplftcorner--rrtoprtcorner-- |
| 150 |
rrbotrtcorner--rrbotlftcorner--cycle withcolor |
| 151 |
rrinnercolor); |
| 152 |
addto name also rrdropshadowpic; |
| 153 |
picture rrtmpborder; |
| 154 |
border := currentpicture; |
| 155 |
if (rrnotop = false): |
| 156 |
rrtmpborder := image(draw rrtopborder withcolor |
| 157 |
rrtopbordercolor withpen rrtopborderpen); |
| 158 |
addto border also rrtmpborder; |
| 159 |
fi |
| 160 |
if (rrnobot = false): |
| 161 |
rrtmpborder := image(draw rrbotborder withcolor |
| 162 |
rrbotbordercolor withpen rrbotborderpen); |
| 163 |
addto border also rrtmpborder; |
| 164 |
fi |
| 165 |
if (rrnolft = false): |
| 166 |
rrtmpborder := image(draw rrlftborder withcolor |
| 167 |
rrlftbordercolor withpen rrlftborderpen); |
| 168 |
addto border also rrtmpborder; |
| 169 |
fi |
| 170 |
if (rrnort = false): |
| 171 |
rrtmpborder := image(draw rrrtborder withcolor |
| 172 |
rrrtbordercolor withpen rrrtborderpen); |
| 173 |
addto border also rrtmpborder; |
| 174 |
fi |
| 175 |
addto name also border; |
| 176 |
rrtext := |
| 177 |
image(label(TEX("\parbox{"&decimal(rrtextwd)&"bp}{"&rrtextalign&rrtextfont&" "&rrbodytext&"}"),(0,0)) withcolor rrtextcolor;); |
| 178 |
addto name also rrtext; |
| 179 |
enddef; |
| 180 |
\endinput |
| 181 |
%% |
| 182 |
%% End of file `roundrect.mp'. |