summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/roundrect
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-08-02 21:30:11 +0000
committerKarl Berry <karl@freefriends.org>2015-08-02 21:30:11 +0000
commit008ccd78c7a2d5abf3e17cb872cf1536f6192ecb (patch)
treecb695f25ce68937d55251cd88fb1a6060c8434a8 /Master/texmf-dist/metapost/roundrect
parent4e51893dc61b666c78c79b6d8e7d62bc7db04a9d (diff)
roundrect (2aug15)
git-svn-id: svn://tug.org/texlive/trunk@38023 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/roundrect')
-rw-r--r--Master/texmf-dist/metapost/roundrect/roundrect.mp219
1 files changed, 94 insertions, 125 deletions
diff --git a/Master/texmf-dist/metapost/roundrect/roundrect.mp b/Master/texmf-dist/metapost/roundrect/roundrect.mp
index e14be7511e4..6dbde535544 100644
--- a/Master/texmf-dist/metapost/roundrect/roundrect.mp
+++ b/Master/texmf-dist/metapost/roundrect/roundrect.mp
@@ -26,55 +26,67 @@
%% roundrect.ins, along with the generated file roundrect.mp
%% and roundrect.pdf, and the README.
-
input TEX;
color rrinnercolor; rrinnercolor := white;
-color rrbordercolor; rrbordercolor := black;
-numeric rrborderwd; rrborderwd := 2pt;
-numeric rrborderrad; rrborderrad := 40pt;
-string rrtitlefont; rrtitlefont := "\fontsize{14pt}{17pt}\selectfont ";
+numeric rrtoprtborderrad; rrtoprtborderrad := 40pt;
+numeric rrbotrtborderrad; rrbotrtborderrad := 40pt;
+numeric rrbotlftborderrad; rrbotlftborderrad := 40pt;
+numeric rrtoplftborderrad; rrtoplftborderrad := 40pt;
+numeric rrtextwd; rrtextwd := 0;
string rrtextfont; rrtextfont := "\fontsize{10pt}{12pt}\selectfont ";
-color rrtitlecolor; rrtitlecolor := black;
color rrtextcolor; rrtextcolor := black;
-color rrtitlebgcolor; rrtitlebgcolor := white;
-color rrtitlebordercolor; rrtitlebordercolor := black;
-boolean rrtitlebar; rrtitlebar := false;
-string rrtitleside; rrtitleside := "top";
-numeric rrtitleht; rrtitleht := 0pt;
-string rrtitlepos; rrtitlepos := "center";
-boolean rrtitlebotborder; rrtitlebotborder := true;
-color rrtitlebotbordercolor; rrtitlebotbordercolor := black;
-string rrtitletext; rrtitletext := "";
string rrbodytext; rrbodytext := "";
-string rrbodyalign; rrbodyalign := "justify";
-string rrbodyaligncom; rrbodyaligncom := "";
+string rrtextalign; rrtextalign := "\centering";
+boolean rrnotop; rrnotop := false;
+boolean rrnobot; rrnobot := false;
+boolean rrnolft; rrnolft := false;
+boolean rrnort; rrnort := false;
+color rrtopbordercolor; rrtopbordercolor := black;
+color rrbotbordercolor; rrbotbordercolor := black;
+color rrlftbordercolor; rrlftbordercolor := black;
+color rrrtbordercolor; rrrtbordercolor := 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;
-rrbordercolor := black;
-rrborderwd := 2pt;
-rrborderrad := 40pt;
-rrtitlefont := "\fontsize{14pt}{17pt}\selectfont ";
+rrnotop := false;
+rrnobot := false;
+rrnolft := false;
+rrnort := false;
+rrtextwd := 0;
rrtextfont := "\fontsize{10pt}{12pt}\selectfont ";
-rrtitlecolor := black;
rrtextcolor := black;
-rrtitlebgcolor := white;
-rrtitlebordercolor := black;
-rrtitlebar := false;
-rrtitleside := "top";
-rrtitleht := 0pt;
-rrtitlepos := "center";
-rrtitlebotborder := true;
-rrtitlebotbordercolor := black;
-rrtitletext := "";
rrbodytext := "";
-rrbodyalign := "justify";
-rrbodyaligncom := "";
+rrtextalign; rrtextalign := "\centering";
enddef;
def roundrect(expr rrht, rrwd)(suffix name) =
TEXPRE("%&latex" & char(10) & "\documentclass{article}\begin{document}");
TEXPOST("\end{document}");
-if (rrtitleht = 0pt):
-rrtitleht := rrht/6;
+if (rrtextwd = 0):
+rrtextwd := rrwd - 12pt;
fi
path rra; path rrb; path rrc; path rrd;
pair a; pair b; pair c; pair d;
@@ -82,14 +94,14 @@ 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 rrborderrad shifted (xpart a +
-(rrborderrad/2),ypart a + (rrborderrad/2));
-rrb := fullcircle scaled rrborderrad shifted (xpart b -
-(rrborderrad/2),ypart b + (rrborderrad/2));
-rrd := fullcircle scaled rrborderrad shifted (xpart d +
-(rrborderrad/2),ypart d - (rrborderrad/2));
-rrc := fullcircle scaled rrborderrad shifted (xpart c -
-(rrborderrad/2),ypart c - (rrborderrad/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;
@@ -100,92 +112,49 @@ pair l; l := (d--a) intersectionpoint rrd;
pair m; m := (d--a) intersectionpoint rra;
picture name;
picture border;
-pair n; pair o; path rrtitlepath; path rrfinalline;
-name := image(fill f--g{right}..{up}h--i{up}..{left}j--
-k{left}..{down}l--m{down}..{right}f--cycle
-withcolor rrinnercolor);
-border := image(pickup pencircle scaled rrborderwd;
-draw f--g{right}..{up}h--i{up}..{left}j--
-k{left}..{down}l--m{down}..{right}f--cycle
-withcolor rrbordercolor);
-addto name also border;
-pair rrtitlestation;
-picture rrtitlelabel;
-if (rrtitlebar):
-if (rrtitleside = "top"):
-n := (xpart m,ypart k - (rrtitleht));
-o := (xpart i,ypart k - (rrtitleht));
-defaultscale := 4;
-if (ypart n > ypart l):
-n := (xpart n,ypart l);
-o := (xpart o,ypart l);
-fi
-rrtitlepath := o--i{up}..{left}j--k{left}..{down}l--n;
-if (rrtitlepos = "center"):
-rrtitlestation := 0.5[n,o] shifted (0,rrtitleht/2);
-elseif (rrtitlepos = "left"):
-rrtitlestation := n shifted (rrborderrad/4,rrtitleht/2);
-elseif (rrtitlepos = "right"):
-rrtitlestation := o shifted (-rrborderrad/4,rrtitleht/2);
+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;
+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
-elseif (rrtitleside = "bot"):
-n := (xpart m,ypart f + (rrtitleht));
-o := (xpart i,ypart f + (rrtitleht));
-if (ypart n < ypart m):
-n := (xpart n,ypart m);
-o := (xpart o,ypart m);
+if (rrnobot = false):
+rrtmpborder := image(draw rrbotborder withcolor
+rrbotbordercolor withpen rrbotborderpen);
+addto border also rrtmpborder;
fi
-rrtitlepath := o--h{down}..{left}g--f{left}..{up}m--n;
-if (rrtitlepos = "center"):
-rrtitlestation := 0.5[n,o] shifted (0,-rrtitleht/2);
-elseif (rrtitlepos = "left"):
-rrtitlestation := n shifted (rrborderrad/4,-rrtitleht/2);
-elseif (rrtitlepos = "right"):
-rrtitlestation := o shifted (-rrborderrad/4,-rrtitleht/2);
+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
-rrfinalline = n--o;
-picture rrtitlepic;
-picture rrtitlepicb;
-picture rrtitlebotborderpic;
-rrtitlebotborderpic := image (draw rrfinalline
-withcolor rrtitlebotbordercolor);
-rrtitlepicb := image(draw rrtitlepath withcolor rrtitlebordercolor);
-if (rrtitlebotborder = true):
-addto rrtitlepicb also rrtitlebotborderpic;
-fi
-rrtitlepath := buildcycle(rrtitlepath,rrfinalline);
-rrtitlepic := image(fill rrtitlepath withcolor rrtitlebgcolor);
-if (rrtitlepos = "center"):
-rrtitlelabel := image(label(TEX(rrtitlefont&" "&rrtitletext),
-rrtitlestation) withcolor rrtitlecolor);
-elseif (rrtitlepos = "left"):
-rrtitlelabel := image(label.rt(TEX(rrtitlefont&" "&rrtitletext),
-rrtitlestation) withcolor rrtitlecolor);
-elseif (rrtitlepos = "right"):
-rrtitlelabel := image(label.lft(TEX(rrtitlefont&" "&rrtitletext),
-rrtitlestation) withcolor rrtitlecolor);
-fi
-if (rrbodyalign = "center"):
-rrbodyaligncom := "\centering ";
-elseif (rrbodyalign = "left"):
-rrbodyaligncom := "\flushleft\vskip-\baselineskip ";
-elseif (rrbodyalign = "right"):
-rrbodyaligncom := "\flushright\vskip-\baselineskip ";
-fi
-picture rrbodytextpic;
-if (rrtitleside = "top"):
-rrbodytextpic :=
-image(label.lrt(TEX("\parbox{"&decimal(rrwd-2rrborderwd-rrborderrad/2)&"bp}{"&rrbodyaligncom&rrtextfont&rrbodytext&"}"),n) withcolor rrtextcolor) shifted (rrborderrad/4,0);
-elseif (rrtitleside = "bot"):
-rrbodytextpic :=
-image(label.urt(TEX("\parbox{"&decimal(rrwd-2rrborderwd-rrborderrad/2)&"bp}{"&rrbodyaligncom&rrtextfont&rrbodytext&"}"),n) withcolor rrtextcolor) shifted (rrborderrad/4,0);
-fi
-addto name also rrtitlepic;
-addto name also rrtitlepicb;
-addto name also rrtitlelabel;
-addto name also rrbodytextpic;
-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;
\endinput
%%