diff options
author | Hans Hagen <pragma@wxs.nl> | 2022-04-01 11:01:40 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2022-04-01 11:01:40 +0200 |
commit | c1224cc330e695938cfcf944f8e9d0c14c15fa8c (patch) | |
tree | 1ab4e67a616e7338f91cded3a0d803d61a185ea3 /metapost | |
parent | 6a2738578157926c6ebd64048ddabb7d923b2be5 (diff) | |
download | context-c1224cc330e695938cfcf944f8e9d0c14c15fa8c.tar.gz |
2022-04-01 09:35:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpxl/mp-apos.mpxl | 58 | ||||
-rw-r--r-- | metapost/context/base/mpxl/mp-luas.mpxl | 1 |
2 files changed, 59 insertions, 0 deletions
diff --git a/metapost/context/base/mpxl/mp-apos.mpxl b/metapost/context/base/mpxl/mp-apos.mpxl index f43712c23..17b7abd92 100644 --- a/metapost/context/base/mpxl/mp-apos.mpxl +++ b/metapost/context/base/mpxl/mp-apos.mpxl @@ -214,3 +214,61 @@ permanent getposleftskip, getposrightskip, getposhsize, getposparindent, getposhangindent, getposhangafter, getposxy, getposupperleft, getposlowerleft, getposupperright, getposlowerright, getposllx, getposlly, getposurx, getposury ; + +def anch_box_arrows_draw = + begingroup ; + save f, t, p, alternative, delta, dashtype, edge ; pair f, t ; path p ; string alternative ; + dashtype := mpvarn("dashtype") ; + delta := mpvard("distance"); + alternative := mpvars("alternative") ; + if positionx(mpvars("rightedge")) > 0 : + if alternative = "left" : + edge := positionx(mpvars("leftedge")); + f := (edge,positiony(mpvars("from"))) ; + t := (edge,positiony(mpvars("to" ))) ; + p := (f -- (f xshifted - delta) -- (t xshifted - delta) -- t) ; + draw thetextext.lft(mpvars("text"), (point .5 along p) xshifted -ExHeight) ; + elseif alternative = "right" : + edge := positionx(mpvars("rightedge")); + f := (edge,positiony(mpvars("from"))) ; + t := (edge,positiony(mpvars("to" ))) ; + p := (f -- (f xshifted delta) -- (t xshifted delta) -- t) ; + draw thetextext.rt(mpvars("text"), (point .5 along p) xshifted ExHeight) ; + elseif alternative = "middle" : + p := f -- t ; + draw thetextext.rt(mpvars("text"), (point .5 along p) xshifted ExHeight) ; + fi ; + else : + f := positionxy(mpvars("from")) ; + t := positionxy(mpvars("to")) ; + if alternative = "bottom" : + f := f yshifted (- abs(ypart f - ypart t)) ; + p := (f -- (f yshifted -delta) -- (t yshifted -delta) -- t) ; + draw thetextext.bot(mpvars("text"), (point .5 along p) yshifted -.25ExHeight) ; + elseif alternative = "top" : + f := f yshifted (abs(ypart f - ypart t)) ; + p := (f -- (f yshifted delta) -- (t yshifted delta) -- t) ; + draw thetextext.top(mpvars("text"), (point .5 along p) yshifted .25ExHeight) ; + elseif alternative = "left" : + f := f xshifted (- abs(xpart f - xpart t)) ; + p := (f -- (f xshifted - delta) -- (t xshifted - delta) -- t) ; + draw thetextext.lft(mpvars("text"), (point .5 along p) xshifted -ExHeight) ; + elseif alternative = "right" : + f := f xshifted (abs(xpart f - xpart t)) ; + p := (f -- (f xshifted delta) -- (t xshifted delta) -- t) ; + draw thetextext.rt(mpvars("text"), (point .5 along p) xshifted ExHeight) ; + elseif alternative = "middle" : + p := f -- t ; + draw thetextext.rt(mpvars("text"), (point .5 along p) xshifted ExHeight) ; + fi ; + fi ; + % 1 = dashed, 2 = dashed with background + drawarrow p + if dashtype == 1 : + withdashes .5ExHeight + fi + withpen pencircle scaled mpvard("rulethickness") + withcolor mpvars("linecolor") ; + positioninregion ; + endgroup ; +enddef ; diff --git a/metapost/context/base/mpxl/mp-luas.mpxl b/metapost/context/base/mpxl/mp-luas.mpxl index 8f093bbfe..f10c3507a 100644 --- a/metapost/context/base/mpxl/mp-luas.mpxl +++ b/metapost/context/base/mpxl/mp-luas.mpxl @@ -415,3 +415,4 @@ permanent permanent matrixbox, matrixspan, matrixcell + |