diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-09-09 09:34:06 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-09-09 09:34:06 +0200 |
commit | bfc2e20d0dfa0dfaf04b0c2c81aed20638f21c91 (patch) | |
tree | fd7f740995f6d2f8169116b0cf6444081f96c6f7 /metapost/context/base/mpiv/mp-tool.mpiv | |
parent | e2902f3463b940beaefaf51ada0b9c37966491b6 (diff) | |
download | context-bfc2e20d0dfa0dfaf04b0c2c81aed20638f21c91.tar.gz |
2016-09-09 08:26:00
Diffstat (limited to 'metapost/context/base/mpiv/mp-tool.mpiv')
-rw-r--r-- | metapost/context/base/mpiv/mp-tool.mpiv | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index 97e817075..40090ccf2 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -2290,7 +2290,7 @@ vardef unspiked expr p = ( path originpath ; originpath := origin -- cycle ; vardef unitvector primary z = - if abs z = abs origin : z else : z/abs z fi + if abs z = abs origin : z else : z/abs z fi % hm, abs origin is just origin enddef; % also new @@ -2973,3 +2973,33 @@ vardef loadmodule expr name = expandafter scantokens expandafter s fi ; enddef ; + +%D Handy for backgrounds: + +def drawpathwithpoints expr p = + do_drawpathwithpoints(p) +enddef ; + +def do_drawpathwithpoints(expr p) text t = + draw p t ; + if length(p) > 2 : + begingroup ; + save _c_ ; path _c_ ; + save _p_; picture _p_ ; + _p_ := image ( + _c_ := if cycle p : fullsquare else : fullcircle fi scaled 6pt ; + for i=0 upto length(p) if cycle p : -1 fi : + fill _c_ shifted point i of p withcolor white ; + draw _c_ shifted point i of p withcolor white/2 withpen pencircle scaled .5pt ; + if (i = 0) and cycle p : + _c_ := fullcircle scaled 6pt ; + fi ; + endfor ; + for i=0 upto length(p) if cycle p : -1 fi : + draw textext("\infofont " & decimal i) ysized 2pt shifted point i of p ; + endfor ; + ) ; + setbounds _p_ to boundingbox p ; + draw _p_ ; + fi ; +enddef ; |