diff options
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpiv/mp-abck.mpiv | 13 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-tool.mpiv | 32 |
2 files changed, 32 insertions, 13 deletions
diff --git a/metapost/context/base/mpiv/mp-abck.mpiv b/metapost/context/base/mpiv/mp-abck.mpiv index abd7d8848..e0c5896e1 100644 --- a/metapost/context/base/mpiv/mp-abck.mpiv +++ b/metapost/context/base/mpiv/mp-abck.mpiv @@ -50,17 +50,6 @@ numeric boxfilloffset ; boxfilloffset := 0 ; numeric boxgriddistance ; boxgriddistance := .5cm ; numeric boxgridshift ; boxgridshift := 0 ; -def abck_show_path(expr p, r, c) = - draw p withpen pencircle scaled .5pt withcolor c ; - if length(p) > 2 : - begingroup ; save _c_ ; path _c_ ; _c_ := fullcircle scaled r ; - 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 withpen pencircle scaled .5pt withcolor c ; - endfor ; - fi ; -enddef ; - vardef abck_draw_path(expr p) = if (length p > 2) and (bbwidth(p) > 1) and (bbheight(p) > 1) : save pp ; path pp ; @@ -160,7 +149,7 @@ enddef ; def show_multi_pars = for i=1 upto nofmultipars : - abck_show_path(multipars[i], 6pt, .5blue) ; + drawpathwithpoints multipars[i] withcolor .5blue ; endfor ; enddef ; 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 ; |