summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/metafun.mp7
-rw-r--r--metapost/context/base/metafun.mpii4
-rw-r--r--metapost/context/base/metafun.mpiv2
-rw-r--r--metapost/context/base/mp-butt.mpii2
-rw-r--r--metapost/context/base/mp-butt.mpiv2
-rw-r--r--metapost/context/base/mp-char.mpii38
-rw-r--r--metapost/context/base/mp-core.mpii4
-rw-r--r--metapost/context/base/mp-core.mpiv2
-rw-r--r--metapost/context/base/mp-figs.mpii2
-rw-r--r--metapost/context/base/mp-figs.mpiv2
-rw-r--r--metapost/context/base/mp-form.mpii30
-rw-r--r--metapost/context/base/mp-form.mpiv4
-rw-r--r--metapost/context/base/mp-grid.mpii2
-rw-r--r--metapost/context/base/mp-grid.mpiv2
-rw-r--r--metapost/context/base/mp-grph.mpii41
-rw-r--r--metapost/context/base/mp-grph.mpiv34
-rw-r--r--metapost/context/base/mp-mlib.mpiv10
-rw-r--r--metapost/context/base/mp-page.mpii6
-rw-r--r--metapost/context/base/mp-page.mpiv66
-rw-r--r--metapost/context/base/mp-shap.mpii2
-rw-r--r--metapost/context/base/mp-shap.mpiv2
-rw-r--r--metapost/context/base/mp-spec.mpii3
-rw-r--r--metapost/context/base/mp-step.mpii2
-rw-r--r--metapost/context/base/mp-tool.mpii4
-rw-r--r--metapost/context/base/mp-tool.mpiv30
25 files changed, 156 insertions, 147 deletions
diff --git a/metapost/context/base/metafun.mp b/metapost/context/base/metafun.mp
index 3c72356cf..ae0a6d6fd 100644
--- a/metapost/context/base/metafun.mp
+++ b/metapost/context/base/metafun.mp
@@ -1,5 +1,8 @@
+if known metafunversion : endinput ; fi ;
+
if known mplib :
- input metafun.mpiv ;
+ input metafun.mpiv
else :
- input metafun.mpii ;
+ input metafun.mpii
fi ;
+
diff --git a/metapost/context/base/metafun.mpii b/metapost/context/base/metafun.mpii
index 374ad88d0..0de186ed2 100644
--- a/metapost/context/base/metafun.mpii
+++ b/metapost/context/base/metafun.mpii
@@ -41,7 +41,7 @@ input "mp-char.mpii" ;
input "mp-step.mpii" ;
input "mp-grph.mpii" ;
input "mp-figs.mpii" ;
-input "mp-form.mpii" ;
+%%%%% "mp-form.mpii" ;
input "mp-grid.mpii" ;
input "mp-func.mpii" ;
@@ -62,4 +62,4 @@ def end =
; message "" ; message metafunversion ; message "" ; normalend ;
enddef ;
-dump ; endinput .
+dump ;
diff --git a/metapost/context/base/metafun.mpiv b/metapost/context/base/metafun.mpiv
index 13dcc85c8..8466e1d83 100644
--- a/metapost/context/base/metafun.mpiv
+++ b/metapost/context/base/metafun.mpiv
@@ -52,5 +52,3 @@ def end =
enddef ;
dump ; % obsolete in mplib
-
-endinput
diff --git a/metapost/context/base/mp-butt.mpii b/metapost/context/base/mp-butt.mpii
index a3599b7c0..5c1edd42e 100644
--- a/metapost/context/base/mp-butt.mpii
+++ b/metapost/context/base/mp-butt.mpii
@@ -75,5 +75,3 @@ def predefinedbutton (expr button_type, button_size, button_linecolor, button_fi
enddef ;
let some_button = predefinedbutton
-
-endinput ;
diff --git a/metapost/context/base/mp-butt.mpiv b/metapost/context/base/mp-butt.mpiv
index a3599b7c0..5c1edd42e 100644
--- a/metapost/context/base/mp-butt.mpiv
+++ b/metapost/context/base/mp-butt.mpiv
@@ -75,5 +75,3 @@ def predefinedbutton (expr button_type, button_size, button_linecolor, button_fi
enddef ;
let some_button = predefinedbutton
-
-endinput ;
diff --git a/metapost/context/base/mp-char.mpii b/metapost/context/base/mp-char.mpii
index 788099f2c..5e7a31c50 100644
--- a/metapost/context/base/mp-char.mpii
+++ b/metapost/context/base/mp-char.mpii
@@ -991,28 +991,16 @@ def end_sub_chart =
endgroup ;
enddef ;
-%D done
-
-endinput ;
-
-%D testing
-
-show_shapes(100) ;
-
-end
-
-%D more testing
-
-show_connections ;
-
-begin_chart (1,4,5) ;
- %clip_chart(1,1,1,2) ;
- new_shape (1,1,31) ;
- new_shape (1,2,3) ;
- new_shape (4,4,5) ;
- connect_top_left (1,1,0) (4,4,0) ;
- connect_bottom_top (1,2,0) (4,4,0) ;
- connect_left_right (1,2,0) (1,1,0) ;
-end_chart ;
-
-end
+% show_shapes(100) ;
+%
+% show_connections ;
+%
+% begin_chart (1,4,5) ;
+% %clip_chart(1,1,1,2) ;
+% new_shape (1,1,31) ;
+% new_shape (1,2,3) ;
+% new_shape (4,4,5) ;
+% connect_top_left (1,1,0) (4,4,0) ;
+% connect_bottom_top (1,2,0) (4,4,0) ;
+% connect_left_right (1,2,0) (1,1,0) ;
+% end_chart ;
diff --git a/metapost/context/base/mp-core.mpii b/metapost/context/base/mp-core.mpii
index 4d28cfd17..c07f0976f 100644
--- a/metapost/context/base/mp-core.mpii
+++ b/metapost/context/base/mp-core.mpii
@@ -1375,10 +1375,6 @@ def ProcessSyncTask(expr p, c) =
fill p withcolor c ;
enddef ;
-endinput ;
-
-end
-
% for Jelle Huisman
%
% \setupcolors[state=start]
diff --git a/metapost/context/base/mp-core.mpiv b/metapost/context/base/mp-core.mpiv
index 1297802e9..6613c5703 100644
--- a/metapost/context/base/mp-core.mpiv
+++ b/metapost/context/base/mp-core.mpiv
@@ -1334,5 +1334,3 @@ enddef ;
def ProcessSyncTask(expr p, c) =
fill p withcolor c ;
enddef ;
-
-endinput ;
diff --git a/metapost/context/base/mp-figs.mpii b/metapost/context/base/mp-figs.mpii
index c90dc3971..aecdc07e7 100644
--- a/metapost/context/base/mp-figs.mpii
+++ b/metapost/context/base/mp-figs.mpii
@@ -45,5 +45,3 @@ let figuredimensions = figuresize ; % for old times sake
def naturalfigure(expr name) =
externalfigure name xyscaled(figuresize(name))
enddef ;
-
-endinput
diff --git a/metapost/context/base/mp-figs.mpiv b/metapost/context/base/mp-figs.mpiv
index c90dc3971..aecdc07e7 100644
--- a/metapost/context/base/mp-figs.mpiv
+++ b/metapost/context/base/mp-figs.mpiv
@@ -45,5 +45,3 @@ let figuredimensions = figuresize ; % for old times sake
def naturalfigure(expr name) =
externalfigure name xyscaled(figuresize(name))
enddef ;
-
-endinput
diff --git a/metapost/context/base/mp-form.mpii b/metapost/context/base/mp-form.mpii
index 60ea4cac2..d1dac32db 100644
--- a/metapost/context/base/mp-form.mpii
+++ b/metapost/context/base/mp-form.mpii
@@ -15,31 +15,15 @@
boolean mant_font ; mant_font := true ; % signals graph not to load form
-if known mplib :
- boolean fmt_loaded ; fmt_loaded := true ;
- expandafter endinput
-fi ;
-
-if known fmt_loaded : expandafter endinput fi ;
- boolean fmt_loaded ; fmt_loaded := true ;
+if known context_form : endinput ; fi ;
-if unknown fmt_precision :
- numeric fmt_precision ; fmt_precision := 3 ;
-fi ;
-
-if unknown fmt_initialize :
- boolean fmt_initialize ; fmt_initialize := true ;
-fi ;
-
-if unknown fmt_separator :
- string fmt_separator ; fmt_separator := "%" ;
-fi ;
-
-if unknown fmt_zerocheck :
- boolean fmt_zerocheck ; fmt_zerocheck := false ;
-fi ;
+boolean context_form ; context_form := true ;
-boolean fmt_metapost ; fmt_metapost := true ; % == use old method
+if unknown fmt_metapost : boolean fmt_metapost ; fmt_metapost := true ; fi ; % == use old method
+if unknown fmt_precision : numeric fmt_precision ; fmt_precision := 3 ; fi ;
+if unknown fmt_initialize : boolean fmt_initialize ; fmt_initialize := true ; fi ;
+if unknown fmt_separator : string fmt_separator ; fmt_separator := "%" ; fi ;
+if unknown fmt_zerocheck : boolean fmt_zerocheck ; fmt_zerocheck := false ; fi ;
% As said, all clever code is from John, the more stupid
% extensions are mine. The following string variables are
diff --git a/metapost/context/base/mp-form.mpiv b/metapost/context/base/mp-form.mpiv
index 8a7ceac16..07b8087e2 100644
--- a/metapost/context/base/mp-form.mpiv
+++ b/metapost/context/base/mp-form.mpiv
@@ -14,6 +14,10 @@
% The graph package will be replaced by our own variant using
% MetaPost 2 features and textext.
+if known context_form : endinput ; fi ;
+
+boolean context_form ; context_form := true ;
+
% The following function accept a number or string that can be
% converted to a number by \LUA. The first argument is a format
% where @ can be used instead of %. The number is typeset in math
diff --git a/metapost/context/base/mp-grid.mpii b/metapost/context/base/mp-grid.mpii
index bfc8dfed6..c49fbeec2 100644
--- a/metapost/context/base/mp-grid.mpii
+++ b/metapost/context/base/mp-grid.mpii
@@ -22,7 +22,7 @@ numeric fmt_precision ; fmt_precision := 3 ;
boolean fmt_initialize ; fmt_initialize := false ;
boolean fmt_zerocheck ; fmt_zerocheck := true ;
-if unknown fmt_loaded : input mp-form ; fi ;
+if unknown fmt_loaded : input "mp-form.mpii" ; fi ;
boolean fmt_pictures ; fmt_pictures := true ;
diff --git a/metapost/context/base/mp-grid.mpiv b/metapost/context/base/mp-grid.mpiv
index 6cb98466e..e7420e4f6 100644
--- a/metapost/context/base/mp-grid.mpiv
+++ b/metapost/context/base/mp-grid.mpiv
@@ -22,7 +22,7 @@ numeric fmt_precision ; fmt_precision := 3 ;
boolean fmt_initialize ; fmt_initialize := false ;
boolean fmt_zerocheck ; fmt_zerocheck := true ;
-if unknown fmt_loaded : input mp-form ; fi ;
+if unknown fmt_loaded : input "mp-form.mpiv" ; fi ;
boolean fmt_pictures ; fmt_pictures := true ;
diff --git a/metapost/context/base/mp-grph.mpii b/metapost/context/base/mp-grph.mpii
index 18183304c..148d9834a 100644
--- a/metapost/context/base/mp-grph.mpii
+++ b/metapost/context/base/mp-grph.mpii
@@ -290,28 +290,21 @@ def graphictextdirective text t =
graphictextstring := graphictextstring & t & CRLF ;
enddef ;
-endinput
-
% example
-
-input mp-grph ;
-
- graphictextformat := "context" ;
-% graphictextformat := "plain" ;
-% graphictextformat := "latex" ; graphictextdirective "\documentclass[]{article}" ;
-
-beginfig (1) ;
- graphictext
- "\vbox{\hsize10cm \input tufte }"
- scaled 8
- withdrawcolor blue
- withfillcolor red
- withpen pencircle scaled 2pt ;
-endfig ;
-
-beginfig(1) ;
- loadfigure "gracht.mp" rotated 20 ;
- loadfigure "koe.mp" number 1 scaled 2 ;
-endfig ;
-
-end
+%
+% % graphictextformat := "context" ;
+% % graphictextformat := "plain" ;
+%
+% beginfig (1) ;
+% graphictext
+% "\vbox{\hsize10cm \input tufte }"
+% scaled 8
+% withdrawcolor blue
+% withfillcolor red
+% withpen pencircle scaled 2pt ;
+% endfig ;
+%
+% beginfig(1) ;
+% loadfigure "gracht.mp" rotated 20 ;
+% loadfigure "koe.mp" number 1 scaled 2 ;
+% endfig ;
diff --git a/metapost/context/base/mp-grph.mpiv b/metapost/context/base/mp-grph.mpiv
index 7291103ec..6e450a92a 100644
--- a/metapost/context/base/mp-grph.mpiv
+++ b/metapost/context/base/mp-grph.mpiv
@@ -238,22 +238,20 @@ def mfun_finish_graphic_text text x_op_x =
endgroup ;
enddef ;
-endinput
-
% example
-
-beginfig (1) ;
- graphictext
- "\vbox{\hsize10cm \input tufte }"
- scaled 8
- withdrawcolor blue
- withfillcolor red
- withpen pencircle scaled 2pt ;
-endfig ;
-
-beginfig(1) ;
- loadfigure "gracht.mp" rotated 20 ;
- loadfigure "koe.mp" number 1 scaled 2 ;
-endfig ;
-
-end
+%
+% beginfig (1) ;
+% graphictext
+% "\vbox{\hsize10cm \input tufte }"
+% scaled 8
+% withdrawcolor blue
+% withfillcolor red
+% withpen pencircle scaled 2pt ;
+% endfig ;
+%
+% beginfig(1) ;
+% loadfigure "gracht.mp" rotated 20 ;
+% loadfigure "koe.mp" number 1 scaled 2 ;
+% endfig ;
+%
+% end
diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv
index fe27bee47..b0b360cee 100644
--- a/metapost/context/base/mp-mlib.mpiv
+++ b/metapost/context/base/mp-mlib.mpiv
@@ -246,7 +246,7 @@ vardef thetextext@#(expr p,z) =
fi
enddef ;
-vardef textext@#(expr p) =
+vardef textext@#(expr p) = % no draw hers
thetextext@#(p,origin)
enddef ;
@@ -262,6 +262,14 @@ def label = % takes two arguments, contrary to textext that takes one
draw thelabel
enddef ;
+vardef anchored@#(expr p, z) = % beware: no "+ mfun_laboff@#" here (never!)
+ p
+ if (mfun_labtype@# >= 10) :
+ shifted (0,ypart center p)
+ fi
+ shifted (z + (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
+enddef ;
+
let normalinfont = infont ;
primarydef str infont name = % nasty hack
diff --git a/metapost/context/base/mp-page.mpii b/metapost/context/base/mp-page.mpii
index 52afacd74..c7542a5f9 100644
--- a/metapost/context/base/mp-page.mpii
+++ b/metapost/context/base/mp-page.mpii
@@ -401,6 +401,8 @@ enddef ;
def StartPage =
+ begingroup ;
+
if PageStateAvailable :
LoadPageState ;
SwapPageState ;
@@ -415,6 +417,8 @@ def StopPage =
BoundPageAreas ;
+ endgroup ;
+
enddef ;
def OverlayBox =
@@ -653,5 +657,3 @@ def page_marks_add_number(expr width, height, length, offset, n) = % todo: names
setbounds currentpicture to page ;
enddef ;
-
-endinput ;
diff --git a/metapost/context/base/mp-page.mpiv b/metapost/context/base/mp-page.mpiv
index e9e0be5b0..e33324b0e 100644
--- a/metapost/context/base/mp-page.mpiv
+++ b/metapost/context/base/mp-page.mpiv
@@ -401,31 +401,77 @@ def SetPageAreas =
enddef ;
def BoundPageAreas =
-
- % pickup pencircle scaled 0pt ;
-
- bboxmargin := 0 ; setbounds currentpicture to Page ;
-
+ % pickup pencircle scaled 0pt ;
+ bboxmargin := 0 ; setbounds currentpicture to Page ;
enddef ;
def StartPage =
-
+ begingroup ;
if PageStateAvailable :
LoadPageState ;
SwapPageState ;
fi ;
-
SetPageAreas ;
BoundPageAreas ;
-
enddef ;
def StopPage =
-
BoundPageAreas ;
+ endgroup ;
+enddef ;
+
+% cover pages
+
+def BoundCoverAreas =
+ % todo: add cropmarks
+ bboxmargin := 0 ; setbounds currentpicture to Paper enlarged PaperBleed ;
+enddef ;
+
+def SetCoverAreas =
+
+ if unknown SpineWidth :
+ SpineWidth := 8mm ;
+ fi ;
+
+ if unknown PaperBleed :
+ PaperBleed := 0 ;
+ fi ;
+
+ FrontPageWidth := PaperWidth ;
+ BackPageWidth := PaperWidth ;
+ PaperWidth := 2 * PaperWidth + SpineWidth ;
+
+ FrontPageHeight := PaperHeight ;
+ BackPageHeight := PaperHeight ;
+ PaperHeight := PaperHeight ;
+ SpineHeight := PaperHeight ;
+
+ path Paper ; Paper := unitsquare xscaled PaperWidth yscaled PaperHeight ;
+ path Spine ; Spine := unitsquare xscaled SpineWidth yscaled PaperHeight shifted (BackPageWidth,0);
+ path BackPage ; BackPage := unitsquare xscaled BackPageWidth yscaled PaperHeight ;
+ path FrontPage ; FrontPage := unitsquare xscaled FrontPageWidth yscaled PaperHeight shifted (BackPageWidth+SpineWidth,0) ;
enddef ;
+
+def StartCover =
+ begingroup ;
+ if PageStateAvailable :
+ LoadPageState ;
+ % SwapPageState ;
+ fi ;
+ SetPageAreas ;
+ SetCoverAreas ;
+ BoundCoverAreas ;
+enddef ;
+
+def StopCover =
+ BoundCoverAreas ;
+ endgroup ;
+enddef ;
+
+% overlays:
+
def OverlayBox =
(unitsquare xyscaled (OverlayWidth,OverlayHeight))
enddef ;
@@ -662,5 +708,3 @@ def page_marks_add_number(expr width, height, length, offset, n) = % todo: names
setbounds currentpicture to page ;
enddef ;
-
-endinput ;
diff --git a/metapost/context/base/mp-shap.mpii b/metapost/context/base/mp-shap.mpii
index a551c4419..291506997 100644
--- a/metapost/context/base/mp-shap.mpii
+++ b/metapost/context/base/mp-shap.mpii
@@ -204,5 +204,3 @@ enddef ;
let drawshape = drawpredefinedshape ;
let drawline = drawpredefinedline ;
-
-endinput ;
diff --git a/metapost/context/base/mp-shap.mpiv b/metapost/context/base/mp-shap.mpiv
index a551c4419..291506997 100644
--- a/metapost/context/base/mp-shap.mpiv
+++ b/metapost/context/base/mp-shap.mpiv
@@ -204,5 +204,3 @@ enddef ;
let drawshape = drawpredefinedshape ;
let drawline = drawpredefinedline ;
-
-endinput ;
diff --git a/metapost/context/base/mp-spec.mpii b/metapost/context/base/mp-spec.mpii
index 25e435edb..7cb960524 100644
--- a/metapost/context/base/mp-spec.mpii
+++ b/metapost/context/base/mp-spec.mpii
@@ -47,7 +47,6 @@
%D for instance shading. More information can be found in
%D type {supp-mpe.tex}.
-if known mplib : endinput ; fi ;
if known context_spec : endinput ; fi ;
boolean context_spec ; context_spec := true ;
@@ -714,8 +713,6 @@ enddef ;
% spotcolor is already scaled
-endinput ;
-
% just an exercise (due to a question by Chof on the context mailing list); scaling of
% 'special' colors is not possible and the next solution is incomplete (spot colors,
% transparency, etc); watch the the tricky chained macro construction
diff --git a/metapost/context/base/mp-step.mpii b/metapost/context/base/mp-step.mpii
index ad6f7bde0..a8d0df8e0 100644
--- a/metapost/context/base/mp-step.mpii
+++ b/metapost/context/base/mp-step.mpii
@@ -166,8 +166,6 @@ vardef get_step_table_line (expr i) =
fi
enddef ;
-endinput
-
%D The older method let \METAPOST\ do the typesetting. The
%D macros needed for that are included here for educational
%D purposes.
diff --git a/metapost/context/base/mp-tool.mpii b/metapost/context/base/mp-tool.mpii
index 7b46c4725..96932d58a 100644
--- a/metapost/context/base/mp-tool.mpii
+++ b/metapost/context/base/mp-tool.mpii
@@ -2562,7 +2562,3 @@ primarydef p snapped s =
fi ; )
p
enddef ;
-
-% done
-
-endinput ;
diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv
index 04d987c8d..79110e752 100644
--- a/metapost/context/base/mp-tool.mpiv
+++ b/metapost/context/base/mp-tool.mpiv
@@ -507,7 +507,7 @@ bcircle = origin -- (-.5,0) & (-.5,0) {down} .. (0,-.5) .. {up} (+.5,0) -- c
lcircle = origin -- (0,+.5) & (0,+.5) {left} .. (-.5,0) .. {right} (0,-.5) -- cycle ;
rcircle = origin -- (0,-.5) & (0,-.5) {right} .. (+.5,0) .. {left} (0,+.5) -- cycle ;
-path urtriangle, ultriangle, lltriangle, lrtriangle ;
+path urtriangle, ultriangle, lltriangle, lrtriangle ; % watch out: it's contrary to what you expect and starts in the origin
urtriangle := origin -- (+.5,0) -- (0,+.5) -- cycle ;
ultriangle := origin -- (0,+.5) -- (-.5,0) -- cycle ;
@@ -1106,6 +1106,15 @@ enddef ;
extra_endfig := extra_endfig & " naturalizepaths ; " ;
+%D Noce tracer:
+
+def drawboundary primary p =
+ draw p dashed evenly withcolor white ;
+ draw p dashed oddly withcolor black ;
+ draw (- llcorner p) withpen pencircle scaled 3 withcolor white ;
+ draw (- llcorner p) withpen pencircle scaled 1.5 withcolor black ;
+enddef ;
+
%D Also handy:
extra_beginfig := extra_beginfig & " truecorners := 0 ; " ; % restores
@@ -1793,6 +1802,15 @@ enddef ;
def [[ = [ [ enddef ; def [[[ = [ [ [ enddef ;
def ]] = ] ] enddef ; def ]]] = ] ] ] enddef ;
+let == = = ;
+
+% added
+
+picture oddly ; % evenly already defined
+
+evenly := dashpattern(on 3 off 3) ;
+oddly := dashpattern(off 3 on 3) ;
+
% not perfect, but useful since it removes redundant points.
vardef mfun_straightened(expr sign, p) =
@@ -1871,9 +1889,9 @@ enddef;
% also new
-vardef anchored@#(expr p, z) = % maybe use the textext variant
- p shifted (z + (labxf@#*lrcorner p + labyf@#*ulcorner p + (1-labxf@#-labyf@#)*llcorner p))
-enddef ;
+% vardef anchored@#(expr p, z) = % maybe use the textext variant
+% p shifted (z + (labxf@#*lrcorner p + labyf@#*ulcorner p + (1-labxf@#-labyf@#)*llcorner p))
+% enddef ;
% epsed(1.2345)
@@ -2139,7 +2157,3 @@ primarydef p snapped s =
)
p
enddef ;
-
-% done
-
-endinput ;