summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-09-09 09:34:06 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-09-09 09:34:06 +0200
commitbfc2e20d0dfa0dfaf04b0c2c81aed20638f21c91 (patch)
treefd7f740995f6d2f8169116b0cf6444081f96c6f7 /metapost
parente2902f3463b940beaefaf51ada0b9c37966491b6 (diff)
downloadcontext-bfc2e20d0dfa0dfaf04b0c2c81aed20638f21c91.tar.gz
2016-09-09 08:26:00
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mpiv/mp-abck.mpiv13
-rw-r--r--metapost/context/base/mpiv/mp-tool.mpiv32
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 ;