summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/context/base/mpxl/mp-apos.mpxl
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/metapost/context/base/mpxl/mp-apos.mpxl')
-rw-r--r--Master/texmf-dist/metapost/context/base/mpxl/mp-apos.mpxl112
1 files changed, 112 insertions, 0 deletions
diff --git a/Master/texmf-dist/metapost/context/base/mpxl/mp-apos.mpxl b/Master/texmf-dist/metapost/context/base/mpxl/mp-apos.mpxl
new file mode 100644
index 00000000000..e3746540f59
--- /dev/null
+++ b/Master/texmf-dist/metapost/context/base/mpxl/mp-apos.mpxl
@@ -0,0 +1,112 @@
+%D \module
+%D [ file=mp-apos.mpiv,
+%D version=2012.02.19, % was mp-core: 1999.08.01, anchoring
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=anchored background macros,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+if known metafun_loaded_apos : endinput ; fi ;
+
+newinternal boolean metafun_loaded_apos ; metafun_loaded_apos := true ; immutable metafun_loaded_apos ;
+
+path posboxes[],
+ posregions[] ;
+
+numeric pospages[],
+ nofposboxes ;
+
+nofposboxes := 0 ;
+
+def boxlineoptions = withcolor .8blue enddef ;
+def boxfilloptions = withcolor .8white enddef ;
+
+mutable posboxes, posregions, pospages, nofposboxes ;
+
+def connect_positions =
+ if nofposboxes = 2 :
+ pickup pencircle scaled boxlinewidth ;
+ path pa ; pa := posboxes[1] enlarged boxlineoffset ;
+ path pb ; pb := posboxes[2] enlarged boxlineoffset ;
+ if pospages[1] = pospages[2] :
+ draw posboxes[1] boxlineoptions ;
+ path pc ; pc := center pa {up} .. {down} center pb ;
+ pair cc ; cc := (pc intersection_point pa) ;
+ if intersection_found :
+ pc := pc cutbefore cc ;
+ cc := (pc intersection_point pb) ;
+ if intersection_found :
+ pc := pc cutafter cc ;
+ drawarrow pc boxlineoptions ;
+ drawarrow reverse pc boxlineoptions ;
+ fi ;
+ fi ;
+ elseif pospages[1] == RealPageNumber :
+ draw posboxes[1] boxlineoptions ;
+ path pc ; pc := center pa {up} ... {right} urcorner (posregions[1] enlarged (20pt,20pt)) ;
+ pair cc ; cc := (pc intersection_point pa) ;
+ if intersection_found :
+ pc := pc cutbefore cc ;
+ drawarrow pc boxlineoptions ;
+ fi ;
+ elseif pospages[2] == RealPageNumber :
+ draw posboxes[2] boxlineoptions ;
+ path pc ; pc := ulcorner (posregions[2] enlarged (20pt,20pt)) {right} ... {down} center pb ;
+ pair cc ; cc := (pc intersection_point pb) ;
+ if intersection_found :
+ pc := pc cutafter cc ;
+ drawarrow pc boxlineoptions ;
+ fi ;
+ fi ;
+ fi ;
+enddef ;
+
+% anch-bar:
+
+def anch_sidebars_draw (expr firstpage, lastpage, yfirst, ylast, height, depth,
+ x, y, w, h, alternative, distance, linewidth, linecolor, topoffset, bottomoffset) =
+ % beware, we anchor at (x,y)
+ begingroup ;
+ if alternative = 1 :
+ interim linecap := rounded ;
+ else :
+ interim linecap := butt ;
+ fi ;
+ save a, b ; pair a, b ;
+ if firstpage = lastpage :
+ a := (-distance,yfirst+height-y) ;
+ b := (-distance,ylast-depth-y) ;
+ elseif RealPageNumber = firstpage :
+ a := (-distance,yfirst+height-y) ;
+ b := (-distance,0) ;
+ elseif RealPageNumber = lastpage :
+ a := (-distance,h) ;
+ b := (-distance,ylast-depth-y) ;
+ else :
+ a := (-distance,h) ;
+ b := (-distance,0) ;
+ fi ;
+ a := (xpart a, min(ypart a + topoffset, h)) ;
+ b := (xpart b, max(ypart b - bottomoffset,0)) ;
+ draw
+ a -- b
+ if alternative = 1 :
+ dashed (withdots scaled (linewidth/2))
+ fi
+ withpen pencircle scaled linewidth
+ withcolor linecolor ;
+ endgroup ;
+enddef ;
+
+% new interface
+
+newscriptindex mfid_getposboxes ; mfid_getposboxes := scriptindex "getposboxes" ;
+newscriptindex mfid_getmultipars ; mfid_getmultipars := scriptindex "getmultipars" ;
+
+def getposboxes (expr tags, anchor) = runscript mfid_getposboxes tags anchor ; enddef ;
+def getmultipars(expr tags, anchor) = runscript mfid_getmultipars tags anchor ; enddef ;