summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/metafun.mpiv3
-rw-r--r--metapost/context/base/mp-abck.mpiv254
-rw-r--r--metapost/context/base/mp-apos.mpiv91
-rw-r--r--metapost/context/base/mp-asnc.mpiv177
-rw-r--r--metapost/context/base/mp-core.mpiv194
-rw-r--r--metapost/context/base/mp-crop.mpiv194
-rw-r--r--metapost/context/base/mp-page.mpiv397
-rw-r--r--metapost/context/base/mp-tool.mpiv2
8 files changed, 912 insertions, 400 deletions
diff --git a/metapost/context/base/metafun.mpiv b/metapost/context/base/metafun.mpiv
index f801717f1..d600764a3 100644
--- a/metapost/context/base/metafun.mpiv
+++ b/metapost/context/base/metafun.mpiv
@@ -19,7 +19,7 @@
input "mp-base.mpiv" ;
input "mp-tool.mpiv" ;
input "mp-mlib.mpiv" ;
-input "mp-core.mpiv" ; % todo: namespace and cleanup
+% "mp-core.mpiv" ; % todo: namespace and cleanup
input "mp-page.mpiv" ; % todo: namespace and cleanup
input "mp-butt.mpiv" ; % todo: namespace and cleanup
input "mp-shap.mpiv" ; % will be improved
@@ -28,7 +28,6 @@ input "mp-grid.mpiv" ; % todo: namespace and cleanup
input "mp-form.mpiv" ; % under (re)construction
input "mp-figs.mpiv" ; % obsolete, needs checking
input "mp-func.mpiv" ; % under construction
-
% "mp-text.mpiv" ; % loaded on demand
% "mp-char.mpiv" ; % loaded on demand
% "mp-step.mpiv" ; % loaded on demand
diff --git a/metapost/context/base/mp-abck.mpiv b/metapost/context/base/mp-abck.mpiv
new file mode 100644
index 000000000..3d5afb903
--- /dev/null
+++ b/metapost/context/base/mp-abck.mpiv
@@ -0,0 +1,254 @@
+%D \module
+%D [ file=mp-abck.mp,
+%D version=2012.02.19, % was mp-core: 1999.08.01, anchoring
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=anchored background macros,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+if known context_abck : endinput ; fi ;
+
+boolean context_abck ; context_abck := true ;
+
+path multiregs[], % region used for multipar (tracing only)
+ multipars[], % effective area (shape)
+ multibox ; % main boundingbox (of main region)
+
+string multikind[] ; % region state: single | first | middle | last (new method)
+
+numeric multilocs[], % 1=begin 2=between 3=end (old method)
+ nofmultipars ; % number of calculated areas
+
+numeric par_strut_height,
+ par_strut_depth,
+ par_line_height ;
+
+nofmultipars := 0 ;
+par_strut_height := 0 ;
+par_strut_depth := 0 ;
+par_line_height := 0 ;
+
+def boxgridoptions = withcolor .8red enddef ;
+def boxlineoptions = withcolor .8blue enddef ;
+def boxfilloptions = withcolor .8white enddef ;
+
+numeric boxgridtype ; boxgridtype := 0 ;
+numeric boxlinetype ; boxlinetype := 1 ;
+numeric boxfilltype ; boxfilltype := 1 ;
+numeric boxdashtype ; boxdashtype := 0 ;
+pair boxgriddirection ; boxgriddirection := up ;
+numeric boxgridwidth ; boxgridwidth := 1pt ;
+numeric boxlinewidth ; boxlinewidth := 1pt ;
+numeric boxlineradius ; boxlineradius := 0 ;
+numeric boxlineoffset ; boxlineoffset := 0 ;
+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 ;
+ pp := p if (boxlineradius>0) and (boxlinetype=2) : cornered boxlineradius fi ;
+ if boxfilltype > 0 :
+ if boxfilloffset > 0 :
+ interim linejoin := mitered ;
+ filldraw pp boxfilloptions withpen pencircle scaled (2*boxfilloffset) ;
+ else :
+ fill pp boxfilloptions ;
+ fi ;
+ fi ;
+ if boxlinetype > 0 :
+ draw pp boxlineoptions withpen pencircle scaled boxlinewidth ;
+ fi ;
+ fi ;
+enddef ;
+
+def abck_grid_line(expr start, width) =
+ % 1 = normal, 2 = with background (i.e. no shine-through)
+ if boxdashtype = 2 :
+ draw start -- start shifted (width,0)
+ withpen pencircle scaled boxgridwidth
+ boxfilloptions ;
+ fi ;
+ draw start -- start shifted (width,0)
+ if boxdashtype > 0 :
+ dashed evenly
+ fi
+ withpen pencircle scaled boxgridwidth
+ boxgridoptions ;
+enddef ;
+
+vardef abck_baseline_grid(expr pxy, pdir, at_baseline) =
+ save width ; width := bbwidth(pxy) ;
+ save height ; height := bbheight(pxy) ;
+ if (par_line_height > 0) and (height > 1) and (width > 1) and (boxgridwidth > 0) :
+ save i, grid, bb ; picture grid ; pair start ; path bb ;
+ grid := image ( % fails with inlinespace
+ if pdir = up :
+ for i = if at_baseline : par_strut_depth else : 0 fi step par_line_height until max(height,par_line_height) :
+ abck_grid_line(llcorner pxy shifted (0,+i),width) ;
+ endfor ;
+ else :
+ for i = if at_baseline : par_strut_height else : 0 fi step par_line_height until height :
+ abck_grid_line(ulcorner pxy shifted (0,-i),width) ;
+ endfor ;
+ fi ;
+ ) ;
+ clip grid to pxy ;
+ bb := boundingbox grid ;
+ grid := grid shifted (0,boxgridshift) ;
+ setbounds grid to bb ;
+ grid
+ else :
+ nullpicture
+ fi
+enddef ;
+
+vardef abck_graphic_grid(expr pxy, dx, dy, x, y) =
+ if (bbheight(pxy) > dy) and (bbwidth(pxy) > dx) and (boxgridwidth > 0) :
+ save grid ; picture grid ;
+ grid := image (
+ for i = xpart llcorner pxy step dx until xpart lrcorner pxy :
+ draw (i,ypart llcorner pxy) -- (i,ypart ulcorner pxy) withpen pencircle scaled boxgridwidth ;
+ endfor ;
+ for i = ypart llcorner pxy step dy until ypart ulcorner pxy :
+ draw (xpart llcorner pxy,i) -- (xpart lrcorner pxy,i) withpen pencircle scaled boxgridwidth ;
+ endfor
+ ) shifted (x,y) ;
+ clip grid to pxy ;
+ grid
+ else :
+ nullpicture
+ fi
+enddef ;
+
+def draw_multi_pars =
+ for i=1 upto nofmultipars :
+ abck_draw_path(multipars[i]) ;
+ if boxgridtype = 1 :
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,true) ;
+ elseif boxgridtype = 2 :
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,false) ;
+ elseif boxgridtype = 3 :
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,true) ;
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,true) shifted (0,ExHeight) ;
+ elseif boxgridtype = 4 :
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,true) shifted (0,ExHeight/2) ;
+ elseif boxgridtype = 11 :
+ draw abck_graphic_grid(multipars[i],boxgriddistance,boxgriddistance,boxgriddistance/2,boxgriddistance/2) ;
+ elseif boxgridtype = 12 :
+ draw abck_graphic_grid(multipars[i],boxgriddistance,boxgriddistance,0,0) ;
+ fi ;
+ endfor ;
+enddef ;
+
+def show_multi_pars =
+ for i=1 upto nofmultipars :
+ abck_show_path(multipars[i], 6pt, .5blue) ;
+ endfor ;
+enddef ;
+
+def show_multi_kind =
+ for i=1 upto nofmultipars :
+ fill multipars[i]
+ withcolor
+ if multikind[i] = "single" : yellow
+ elseif multikind[i] = "first" : red
+ elseif multikind[i] = "middle" : green
+ elseif multikind[i] = "last" : blue
+ fi
+ withtransparency (1,.5)
+ ;
+ endfor ;
+enddef ;
+
+def draw_multi_side =
+ begingroup ; save p ; picture p ;
+ for i=1 upto nofmultipars :
+ p := image ( fill leftboundary multipars[i]
+ shifted (-boxlineoffset,0)
+ rightenlarged boxlinewidth boxlineoptions ;
+ ) ;
+ setbounds p to multipars[i] ;
+ draw p ;
+ endfor ;
+ endgroup ;
+enddef ;
+
+% some extras
+
+path posboxes[],
+ posregions[] ;
+
+numeric multipages[],
+ nofposboxes ;
+
+nofposboxes := 0 ;
+
+% For the moment we keep these as they can be in use but they will
+% disappear.
+
+pair lxy[], rxy[], cxy[], llxy[], lrxy[], ulxy[], urxy[] ;
+path pxy[] ;
+numeric hxy[], wxy[], dxy[], nxy[] ;
+
+def box_found (expr n,x,y,w,h,d) =
+ not ((x=0) and (y=0) and (w=0) and (h=0) and (d=0))
+enddef ;
+
+def initialize_box_pos (expr pos,n,x,y,w,h,d) =
+ pair lxy, rxy, cxy, llxy, lrxy, ulxy, urxy ;
+ path pxy ; numeric hxy, wxy, dxy, nxy;
+ lxy := (x,y) ;
+ llxy := (x,y-d) ;
+ lrxy := (x+w,y-d) ;
+ urxy := (x+w,y+h) ;
+ ulxy := (x,y+h) ;
+ wxy := w ;
+ hxy := h ;
+ dxy := d ;
+ rxy := lxy shifted (wxy,0) ;
+ pxy := llxy--lrxy--urxy--ulxy--cycle ;
+ cxy := center pxy ;
+ nxy := n ;
+ freeze_box(pos) ;
+enddef ;
+
+def freeze_box (expr pos) =
+ lxy[pos] := lxy ;
+ llxy[pos] := llxy ;
+ lrxy[pos] := lrxy ;
+ urxy[pos] := urxy ;
+ ulxy[pos] := ulxy ;
+ wxy[pos] := wxy ;
+ hxy[pos] := hxy ;
+ dxy[pos] := dxy ;
+ rxy[pos] := rxy ;
+ pxy[pos] := pxy ;
+ cxy[pos] := cxy ;
+ nxy[pos] := nxy ;
+enddef ;
+
+def initialize_box (expr n,x,y,w,h,d) =
+ numeric bpos ; bpos := 0 ; initialize_box_pos(bpos,n,x,y,w,h,d) ;
+enddef ;
+
+def anchor_box (expr n,x,y,w,h,d) =
+ currentpicture := currentpicture shifted (-x,-y) ;
+enddef ;
diff --git a/metapost/context/base/mp-apos.mpiv b/metapost/context/base/mp-apos.mpiv
new file mode 100644
index 000000000..072c958f3
--- /dev/null
+++ b/metapost/context/base/mp-apos.mpiv
@@ -0,0 +1,91 @@
+%D \module
+%D [ file=mp-apos.mp,
+%D version=2012.02.19, % was mp-core: 1999.08.01, anchoring
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=anchored background macros,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+if known context_apos : endinput ; fi ;
+
+boolean context_apos ; context_apos := true ;
+
+path posboxes[],
+ posregions[] ;
+
+numeric multipages[],
+ nofposboxes ;
+
+nofposboxes := 0 ;
+
+def boxlineoptions = withcolor .8blue enddef ;
+def boxfilloptions = withcolor .8white enddef ;
+
+def connect_positions =
+ if nofposboxes = 2 :
+ pickup pencircle scaled boxlinewidth ;
+ path pa ; pa := posboxes[1] enlarged boxlineoffset ;
+ path pb ; pb := posboxes[2] enlarged boxlineoffset ;
+ if pospages[1] = pospages[2] :
+ draw posboxes[1] boxlineoptions ;
+ path pc ; pc := center pa {up} .. {down} center pb ;
+ pair cc ; cc := (pc intersection_point pa) ;
+ if intersection_found :
+ pc := pc cutbefore cc ;
+ cc := (pc intersection_point pb) ;
+ if intersection_found :
+ pc := pc cutafter cc ;
+ drawarrow pc boxlineoptions ;
+ drawarrow reverse pc boxlineoptions ;
+ fi ;
+ fi ;
+ elseif pospages[1] == RealPageNumber :
+ draw posboxes[1] boxlineoptions ;
+ path pc ; pc := center pa {up} ... {right} urcorner (posregions[1] enlarged (20pt,20pt)) ;
+ pair cc ; cc := (pc intersection_point pa) ;
+ if intersection_found :
+ pc := pc cutbefore cc ;
+ drawarrow pc boxlineoptions ;
+ fi ;
+ elseif pospages[2] == RealPageNumber :
+ draw posboxes[2] boxlineoptions ;
+ path pc ; pc := ulcorner (posregions[2] enlarged (20pt,20pt)) {right} ... {down} center pb ;
+ pair cc ; cc := (pc intersection_point pb) ;
+ if intersection_found :
+ pc := pc cutafter cc ;
+ drawarrow pc boxlineoptions ;
+ fi ;
+ fi ;
+ fi ;
+enddef ;
+
+% anch-bar:
+
+def anch_sidebars_draw(expr p_b_self, p_e_self, y_b_self, y_e_self, h_b_self, d_e_self, distance, linewidth, linecolor) =
+ StartPage ;
+ path p ; p :=
+ if p_b_self=p_e_self :
+ (xpart ulcorner Field[Text][Text],y_b_self+h_b_self) --
+ (xpart llcorner Field[Text][Text],y_e_self-d_e_self) ;
+ elseif RealPageNumber=p_b_self :
+ (xpart ulcorner Field[Text][Text],y_b_self+h_b_self) --
+ (llcorner Field[Text][Text]) ;
+ elseif RealPageNumber=p_e_self :
+ (ulcorner Field[Text][Text]) --
+ (xpart llcorner Field[Text][Text],y_e_self-d_e_self) ;
+ else :
+ (ulcorner Field[Text][Text]) --
+ (llcorner Field[Text][Text]) ;
+ fi ;
+ p := p shifted (-llcorner Field[Text][Text]-(distance,0)) ;
+ interim linecap := butt ;
+ draw p
+ withpen pencircle scaled linewidth
+ withcolor linecolor ;
+ StopPage ;
+enddef ;
diff --git a/metapost/context/base/mp-asnc.mpiv b/metapost/context/base/mp-asnc.mpiv
new file mode 100644
index 000000000..cfee782e7
--- /dev/null
+++ b/metapost/context/base/mp-asnc.mpiv
@@ -0,0 +1,177 @@
+%D \module
+%D [ file=mp-asnc.mp,
+%D version=2012.02.19, % was mp-core: 1999.08.01, anchoring
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=anchored background macros,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+if known context_asnc : endinput ; fi ;
+
+boolean context_av ; context_asnc := true ;
+
+% will be replaced
+
+numeric sync_n[], sync_p[][], sync_w[][], sync_h[][], sync_d[][], sync_t[][] ;
+pair sync_xy[][] ; color sync_c[][] ;
+
+def ResetSyncTasks =
+ path SyncPaths[] ; numeric SyncTasks[], NOfSyncPaths, CurrentSyncClass ;
+ NOfSyncPaths := CurrentSyncClass := 0 ;
+ if unknown SyncLeftOffset : numeric SyncLeftOffset ; SyncLeftOffset := 0 ; fi ;
+ if unknown SyncWidth : numeric SyncWidth ; SyncWidth := 0 ; fi ;
+ if unknown SyncThreshold : numeric SyncThreshold ; SyncThreshold := LineHeight ; fi ;
+ if unknown SyncColor : color SyncColor ; SyncColor := .5white ; fi ;
+ if (SyncLeftOffset = 0) and (SyncWidth = 0) :
+ SyncWidth := if known TextWidth : TextWidth else : -1cm fi ;
+ fi ;
+enddef ;
+
+ResetSyncTasks ;
+
+vardef SyncBox(expr n, i, leftoffset, width, topoffset, bottomoffset) =
+ save o ; pair o ; o := (xpart llcorner PlainTextArea,ypart sync_xy[n][i]) ;
+ o shifted (leftoffset,sync_h[n][i]+topoffset) --
+ o shifted (width+leftoffset,sync_h[n][i]+topoffset) --
+ o shifted (width+leftoffset,bottomoffset) --
+ o shifted (leftoffset,bottomoffset) -- cycle
+enddef ;
+
+def SetSyncColor(expr n, i, c) =
+ sync_c[n][i] := c ;
+enddef ;
+
+def SetSyncThreshold(expr n, i, th) =
+ sync_th[n][i] := th ;
+enddef ;
+
+vardef TheSyncColor(expr n, i) =
+ if known sync_c[n][i] : sync_c[n][i] else : SyncColor fi
+enddef ;
+
+vardef TheSyncThreshold(expr n, i) =
+ if known sync_th[n][i] : sync_th[n][i] else : SyncThreshold fi
+enddef ;
+
+vardef PrepareSyncTasks(expr n, collapse, extendtop, prestartnext) =
+ ResetSyncTasks ;
+ if known sync_n[n] :
+ CurrentSyncClass := n ;
+ save ok, l, d ; boolean ok ; ok := false ; NOfSyncPaths := l := 0 ;
+ for i=1 upto sync_n[n] :
+ if RealPageNumber > sync_p[n][i] :
+ l := i ;
+ elseif RealPageNumber = sync_p[n][i] :
+ NOfSyncPaths := NOfSyncPaths + 1 ;
+ if not ok :
+ if i>1 :
+ if sync_t[n][i-1] = sync_t[n][i] :
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i, SyncLeftOffset, SyncWidth, PaperHeight, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i ;
+ else :
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i-1, SyncLeftOffset, SyncWidth, PaperHeight, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i-1 ;
+ NOfSyncPaths := NOfSyncPaths + 1 ;
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i, SyncLeftOffset, SyncWidth, 0, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i ;
+ fi ;
+ else :
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i, SyncLeftOffset, SyncWidth, 0, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i ;
+ fi ;
+ else :
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i, SyncLeftOffset, SyncWidth, 0, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i ;
+ fi ;
+ ok := true ;
+ fi ;
+ endfor ;
+ if (NOfSyncPaths = 0) and (l > 0) :
+ NOfSyncPaths := 1 ;
+ SyncPaths[NOfSyncPaths] := SyncBox(n, l, SyncLeftOffset, SyncWidth, PaperHeight, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := l ;
+ fi ;
+ if NOfSyncPaths > 0 :
+ for i = 1 upto NOfSyncPaths-1 :
+ SyncPaths[i] := topboundary SyncPaths[i] -- reverse topboundary SyncPaths[i+1] -- cycle ;
+ endfor ;
+ if unknown SyncThresholdMethod :
+ numeric SyncThresholdMethod ; SyncThresholdMethod := 2 ;
+ fi ;
+ if extendtop :
+ if SyncThresholdMethod = 1 :
+ if NOfSyncPaths>1 :
+ d := ypart (ulcorner PlainTextArea - sync_xy[n][SyncTasks[2]]) ;
+ if (SyncTasks[2]>1) and (d > 0pt) and (d <= TheSyncThreshold(n,sync_t[n][SyncTasks[2]])) and (sync_p[n][SyncTasks[2]] = RealPageNumber) :
+ SyncPaths[2] := SyncPaths[2] topenlarged PaperHeight ;
+ fi ;
+ fi ;
+ else :
+ for i = 1 upto NOfSyncPaths :
+ d := ypart (ulcorner PlainTextArea - sync_xy[n][SyncTasks[i]]) ;
+ if (d > 0) and (d <= TheSyncThreshold(n,sync_t[n][SyncTasks[i]])) and (sync_p[n][SyncTasks[i]] = RealPageNumber) :
+ SyncPaths[i] := SyncPaths[i] topenlarged PaperHeight ;
+ fi ;
+ endfor ;
+ fi ;
+ fi ;
+ if prestartnext :
+ if NOfSyncPaths>1 :
+ if SyncTasks[NOfSyncPaths] < sync_n[n] : % there is a next one
+ d := ypart (ulcorner PlainTextArea - sync_xy[n][SyncTasks[NOfSyncPaths]+1]) ;
+ if (d > 0) and (d <= TheSyncThreshold(n, sync_t[n][SyncTasks[i]])) and (sync_p[n][SyncTasks[NOfSyncPaths]+1] = RealPageNumber+1) :
+ SyncPaths[NOfSyncPaths+1] :=
+ (xpart ulcorner SyncPaths[NOfSyncPaths],ypart llcorner PlainTextArea) --
+ (xpart urcorner SyncPaths[NOfSyncPaths],ypart llcorner PlainTextArea) --
+ lrcorner SyncPaths[NOfSyncPaths] --
+ llcorner SyncPaths[NOfSyncPaths] -- cycle ;
+ SyncTasks[NOfSyncPaths+1] := SyncTasks[NOfSyncPaths]+1 ;
+ NOfSyncPaths := NOfSyncPaths + 1 ;
+ fi ;
+ fi ;
+ fi ;
+ else :
+ if NOfSyncPaths>1 :
+ d := ypart (sync_xy[n][SyncTasks[NOfSyncPaths]] - llcorner PlainTextArea) ;
+ if (d < TheSyncThreshold(n, SyncTasks[NOfSyncPaths])) :
+ NOfSyncPaths := NOfSyncPaths - 1 ;
+ SyncPaths[NOfSyncPaths] := SyncPaths[NOfSyncPaths] bottomenlarged PaperHeight ;
+ fi ;
+ fi ;
+ fi ;
+ if (NOfSyncPaths>1) and collapse :
+ save j ; numeric j ; j := 1 ;
+ for i = 2 upto NOfSyncPaths :
+ if sync_t[n][SyncTasks[i]] = sync_t[n][SyncTasks[j]] :
+ SyncPaths[j] := boundingbox image (draw SyncPaths[i] ; draw SyncPaths[j] ; ) ;
+ SyncTasks[j] := SyncTasks[i] ;
+ else :
+ j := j + 1 ;
+ SyncPaths[j] := SyncPaths[i] ;
+ SyncTasks[j] := SyncTasks[i] ;
+ fi ;
+ endfor ;
+ NOfSyncPaths := j ;
+ fi ;
+ fi ;
+ fi ;
+enddef ;
+
+def SyncTask(expr n) =
+ if known SyncTasks[n] : SyncTasks[n] else : 0 fi
+enddef ;
+
+def FlushSyncTasks =
+ for i = 1 upto NOfSyncPaths :
+ ProcessSyncTask(SyncPaths[i], TheSyncColor(CurrentSyncClass,sync_t[CurrentSyncClass][SyncTasks[i]])) ;
+ endfor ;
+enddef ;
+
+def ProcessSyncTask(expr p, c) =
+ fill p withcolor c ;
+enddef ;
diff --git a/metapost/context/base/mp-core.mpiv b/metapost/context/base/mp-core.mpiv
index c0718397d..fd0b8bb9c 100644
--- a/metapost/context/base/mp-core.mpiv
+++ b/metapost/context/base/mp-core.mpiv
@@ -15,6 +15,200 @@ if known context_core : endinput ; fi ;
boolean context_core ; context_core := true ;
+%D Copied to here .. not used any more.
+
+def SaveTextAreas =
+ path SavedTextAreas [] ;
+ path SavedTextColumns[] ;
+ numeric NOfSavedTextAreas ;
+ numeric NOfSavedTextColumns ;
+ for i=1 upto NOfTextAreas :
+ SavedTextAreas[i] := TextAreas[i] ;
+ endfor ;
+ for i=1 upto NOfTextColumns :
+ SavedTextColumns[i] := TextColumns[i] ;
+ endfor ;
+ NOfSavedTextAreas := NOfTextAreas ;
+ NOfSavedTextColumns := NOfTextColumns ;
+enddef ;
+
+def ResetTextAreas =
+ path TextAreas[], TextColumns[], PlainTextArea, RegionTextArea ;
+ numeric NOfTextAreas ; NOfTextAreas := 0 ;
+ numeric NOfTextColumns ; NOfTextColumns := 0 ;
+ numeric nofmultipars ; nofmultipars := 0 ;
+ TextAreas[0] := TextColumns[0] := origin -- cycle ;
+enddef ;
+
+ResetTextAreas ; SaveTextAreas ; ;
+
+def RegisterTextArea (expr x, y, w, h, d) =
+ begingroup ;
+ save p ; path p ;
+ p := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
+ if NOfTextAreas>0 :
+ % if needed, concatenate areas
+ if (round(llcorner TextAreas[NOfTextAreas]) = round(ulcorner p)) and
+ (round(lrcorner TextAreas[NOfTextAreas]) = round(urcorner p)) :
+ p :=
+ ulcorner TextAreas[NOfTextAreas] --
+ urcorner TextAreas[NOfTextAreas] --
+ lrcorner p --
+ llcorner p -- cycle ;
+ else :
+ NOfTextAreas := NOfTextAreas + 1 ;
+ fi ;
+ else :
+ NOfTextAreas := NOfTextAreas + 1 ;
+ fi ;
+ TextAreas[NOfTextAreas] := p ;
+ if NOfTextColumns>0 :
+ if (round(xpart llcorner TextColumns[NOfTextColumns]) = round(xpart ulcorner p)) and
+ (round(xpart lrcorner TextColumns[NOfTextColumns]) = round(xpart urcorner p)) :
+ p :=
+ ulcorner TextColumns[NOfTextColumns] --
+ urcorner TextColumns[NOfTextColumns] --
+ lrcorner p --
+ llcorner p -- cycle ;
+ else :
+ NOfTextColumns := NOfTextColumns + 1 ;
+ fi ;
+ else :
+ NOfTextColumns := NOfTextColumns + 1 ;
+ fi ;
+ TextColumns[NOfTextColumns] := p ;
+ endgroup ;
+enddef ;
+
+%D We store a local area in slot zero.
+
+def RegisterPlainTextArea(expr x,y,w,h,d) =
+ PlainTextArea := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
+enddef ;
+
+def RegisterRegionTextArea(expr x,y,w,h,d) =
+ RegionTextArea := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
+ % RegionTextArea := RegionTextArea enlarged 2mm ;
+enddef ;
+
+def RegisterLocalTextArea (expr x, y, w, h, d) =
+ TextAreas[0] := TextColumns[0] := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
+enddef ;
+
+def ResetLocalTextArea =
+ TextAreas[0] := TextColumns[0] := origin -- cycle ;
+enddef ;
+
+ResetLocalTextArea ;
+
+vardef InsideTextArea (expr _i_, _xy_) =
+ (round(xpart _xy_) >= round(xpart llcorner TextAreas[_i_])) and
+ (round(xpart _xy_) <= round(xpart lrcorner TextAreas[_i_])) and
+ (round(ypart _xy_) >= round(ypart llcorner TextAreas[_i_])) and
+ (round(ypart _xy_) <= round(ypart urcorner TextAreas[_i_]))
+enddef ;
+
+vardef InsideSavedTextArea (expr _i_, _xy_) =
+ (round(xpart _xy_) >= round(xpart llcorner SavedTextAreas[_i_])) and
+ (round(xpart _xy_) <= round(xpart lrcorner SavedTextAreas[_i_])) and
+ (round(ypart _xy_) >= round(ypart llcorner SavedTextAreas[_i_])) and
+ (round(ypart _xy_) <= round(ypart urcorner SavedTextAreas[_i_]))
+enddef ;
+
+vardef InsideSomeTextArea (expr _xy_) =
+ save ok ; boolean ok ; ok := false ;
+ for i := 1 upto NOfTextAreas :
+ if InsideTextArea(i,_xy_) :
+ ok := true ; % we can move the exit here
+ fi ;
+ exitif ok ;
+ endfor ;
+ ok
+enddef ;
+
+vardef InsideSomeSavedTextArea (expr _xy_) =
+ save ok ; boolean ok ; ok := false ;
+ for i := 1 upto NOfSavedTextAreas :
+ if InsideSavedTextArea(i,_xy_) :
+ ok := true ;
+ fi ;
+ exitif ok ;
+ endfor ;
+ ok
+enddef ;
+
+vardef TextAreaX (expr x) =
+ numeric _TextAreaX_ ; _TextAreaX_ := 0 ;
+ for i := 1 upto NOfTextAreas :
+ if (round(x) >= round(xpart llcorner TextAreas[i])) and
+ (round(x) <= round(xpart lrcorner TextAreas[i])) :
+ _TextAreaX_ := xpart llcorner TextAreas[i] ;
+ fi ;
+ endfor ;
+ _TextAreaX_
+enddef ;
+
+vardef TextAreaY (expr y) =
+ numeric _TextAreaY_ ; _TextAreaY_ := 0 ;
+ for i := 1 upto NOfTextAreas :
+ if (round(y) >= round(ypart llcorner TextAreas[NOfTextAreas])) and
+ (round(y) <= round(ypart ulcorner TextAreas[NOfTextAreas])) :
+ _TextAreaY_ := ypart llcorner TextAreas[NOfTextAreas] ;
+ fi ;
+ endfor ;
+ _TextAreaY_
+enddef ;
+
+vardef TextAreaXY (expr x, y) =
+ pair _TextAreaXY_ ; _TextAreaXY_ := origin ;
+ for i := 1 upto NOfTextAreas :
+ if (round(x) >= round(xpart llcorner TextAreas[i])) and
+ (round(x) <= round(xpart lrcorner TextAreas[i])) and
+ (round(y) >= round(ypart llcorner TextAreas[i])) and
+ (round(y) <= round(ypart ulcorner TextAreas[i])) :
+ _TextAreaXY_ := llconer TextAreas[i] ;
+ fi ;
+ endfor ;
+ _TextAreaXY_
+enddef ;
+
+vardef TextAreaW (expr x) =
+ numeric _TextAreaW_ ; _TextAreaW_ := 0 ;
+ for i := 1 upto NOfTextAreas :
+ if (round(x) >= round(xpart llcorner TextAreas[i])) and
+ (round(x) <= round(xpart lrcorner TextAreas[i])) :
+ _TextAreaW_ := bbwidth(TextAreas[i]) ;
+ fi ;
+ endfor ;
+ _TextAreaW_
+enddef ;
+
+vardef TextAreaH (expr y) =
+ numeric _TextAreaH_ ; _TextAreaH_ := 0 ;
+ for i := 1 upto NOfTextAreas :
+ if (round(y) >= round(ypart llcorner TextAreas[i])) and
+ (round(y) <= round(ypart ulcorner TextAreas[i])) :
+ _TextAreaH_ := bbheight(TextAreas[i]) ;
+ fi ;
+ endfor ;
+ _TextAreaH_
+enddef ;
+
+vardef TextAreaWH (expr x, y) =
+ pair _TextAreaWH_ ; _TextAreaWH_ := origin ;
+ for i := 1 upto NOfTextAreas :
+ if (round(x) >= round(xpart llcorner TextAreas[i])) and
+ (round(x) <= round(xpart lrcorner TextAreas[i])) and
+ (round(y) >= round(ypart llcorner TextAreas[i])) and
+ (round(y) <= round(ypart ulcorner TextAreas[i])) :
+ _TextAreaWH_ := (bbwidth(TextAreas[i]),bbheight(TextAreas[i])) ;
+ fi ;
+ endfor ;
+ _TextAreaWH_
+enddef ;
+
+%D Till here.
+
pair lxy[], rxy[], cxy[], llxy[], lrxy[], ulxy[], urxy[] ;
path pxy[] ;
numeric hxy[], wxy[], dxy[], nxy[] ;
diff --git a/metapost/context/base/mp-crop.mpiv b/metapost/context/base/mp-crop.mpiv
new file mode 100644
index 000000000..260823e68
--- /dev/null
+++ b/metapost/context/base/mp-crop.mpiv
@@ -0,0 +1,194 @@
+%D \module
+%D [ file=mp-crop.mp,
+%D version=2011.06.23,
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=Cropmarks,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+if known context_crop : endinput ; fi ;
+
+boolean context_crop ; context_crop := true ;
+
+vardef crop_marks_lines (expr box, length, offset, nx, ny) =
+ save p ; picture p ; save w, h, x, y ; numeric w, h, x, y ;
+ p := image (
+ x := if nx = 0 : 1 else : nx - 1 fi ;
+ y := if ny = 0 : 1 else : ny - 1 fi ;
+ w := bbwidth (box) / x ;
+ h := bbheight(box) / y ;
+ for i=0 upto y :
+ draw ((llcorner box) -- (llcorner box) shifted (-length,0)) shifted (-offset,i*h) ;
+ draw ((lrcorner box) -- (lrcorner box) shifted ( length,0)) shifted ( offset,i*h) ;
+ endfor ;
+ for i=0 upto x :
+ draw ((llcorner box) -- (llcorner box) shifted (0,-length)) shifted (i*w,-offset) ;
+ draw ((ulcorner box) -- (ulcorner box) shifted (0, length)) shifted (i*w, offset) ;
+ endfor ;
+ ) ;
+ setbounds p to box ;
+ p
+enddef ;
+
+vardef crop_marks_cmyk =
+ save p ; picture p ; p := image (
+ fill ulcircle scaled 12.5 withcolor (1,0,0,0) ;
+ fill urcircle scaled 12.5 withcolor (0,1,0,0) ;
+ fill lrcircle scaled 12.5 withcolor (0,0,1,0) ;
+ fill llcircle scaled 12.5 withcolor (0,0,0,1) ;
+ draw (-10,0) -- (10,0) ;
+ draw (0,-10) -- (0,10) ;
+ draw fullcircle scaled 12.5 ;
+ ) ;
+ setbounds p to fullsquare scaled 20 ;
+ p
+enddef ;
+
+vardef crop_marks_gray =
+ save p ; picture p ; p := image (
+ fill ulcircle scaled 12.5 withcolor (0.00) ;
+ fill urcircle scaled 12.5 withcolor (0.25) ;
+ fill lrcircle scaled 12.5 withcolor (0.50) ;
+ fill llcircle scaled 12.5 withcolor (0.75) ;
+ draw (-10,0) -- (10,0) ;
+ draw (0,-10) -- (0,10) ;
+ draw (-6,0) -- (6,0) withcolor white ;
+ draw (0,-6) -- (0,6) withcolor white ;
+ draw fullcircle scaled 12.5 ;
+ ) ;
+ setbounds p to fullsquare scaled 20 ;
+ p
+enddef ;
+
+vardef crop_marks_cmykrgb =
+ save p ; picture p ; p := image (
+ fill ulcircle scaled 15 withcolor (1,0,0) ;
+ fill urcircle scaled 15 withcolor (0,1,0) ;
+ fill lrcircle scaled 15 withcolor (0,0,1) ;
+ fill llcircle scaled 15 withcolor (.5,.5,.5) ;
+ fill ulcircle scaled 10 withcolor (1,0,0,0) ;
+ fill urcircle scaled 10 withcolor (0,1,0,0) ;
+ fill lrcircle scaled 10 withcolor (0,0,1,0) ;
+ fill llcircle scaled 10 withcolor (0,0,0,1) ;
+ draw (-10,0) -- (10,0) ;
+ draw (0,-10) -- (0,10) ;
+ draw fullcircle scaled 10 ;
+ draw fullcircle scaled 15 ;
+ ) ;
+ setbounds p to fullsquare scaled 20 ;
+ p
+enddef ;
+
+vardef crop_color(expr c, h, w, dx, dy, ts) =
+ image (
+ save p ; path p ;
+ for i=1 upto 6 :
+ p := fullsquare
+ xscaled w
+ yscaled h
+ shifted (dx,dy-i*h) ;
+ fill p
+ withcolor (crop_colors[i]*c) ;
+ draw textext("\format{'@0.2f'," & decimal crop_colors[i] & "}")
+ scaled ts
+ shifted center p withcolor white ;
+ endfor ;
+ )
+enddef ;
+
+vardef crop_gray(expr c, h, w, dx, dy, ts) =
+ image (
+ save p ; path p ;
+ for i=.05 step .05 until 1 :
+ p := fullsquare
+ xscaled w
+ yscaled h
+ shifted (20*(i-1)*w+dx,dy) ;
+ fill p
+ withcolor (i*c) ;
+ draw textext("\format{'@0.2f'," & decimal i & "}")
+ scaled ts
+ shifted center p withcolor white ;
+ endfor ;
+ )
+enddef ;
+
+% draw crop_marks_cmyk shifted llcorner more ;
+% draw crop_marks_cmyk shifted lrcorner more ;
+% draw crop_marks_cmyk shifted ulcorner more ;
+% draw crop_marks_cmyk shifted urcorner more ;
+
+def page_marks_add_color(expr width, height, length, offset) = % todo: namespace
+
+ path page ; page := fullsquare xscaled width yscaled height ;
+ path more ; more := page enlarged (offset+length/2,offset+length/2) ;
+
+ numeric crop_colors[] ;
+ crop_colors[1] := 1 ;
+ crop_colors[2] := 0.95 ;
+ crop_colors[3] := 0.75 ;
+ crop_colors[4] := 0.50 ;
+ crop_colors[5] := 0.25 ;
+ crop_colors[6] := 0.05 ;
+
+ numeric h ; h := height / 20 ;
+ numeric w ; w := width / 20 ;
+ numeric d ; d := offset + length/2 ;
+
+ draw crop_color((1,0,0,0),h,length,xpart ulcorner page - d, 10h,length/20) ;
+ draw crop_color((0,1,0,0),h,length,xpart ulcorner page - d,3.5h,length/20) ;
+ draw crop_color((0,0,1,0),h,length,xpart ulcorner page - d, -3h,length/20) ;
+
+ draw crop_color((0,1,1,0),h,length,xpart urcorner page + d, 10h,length/20) ;
+ draw crop_color((1,0,1,0),h,length,xpart urcorner page + d,3.5h,length/20) ;
+ draw crop_color((1,1,0,0),h,length,xpart urcorner page + d, -3h,length/20) ;
+
+ draw crop_gray((0,0,0,1),length, w,-xpart llcorner page,-ypart llcorner page + d ,w/20) ;
+ draw crop_gray((1,0,0,0),length/3,w,-xpart llcorner page, ypart llcorner page - d + 1length/3,w/20) ;
+ draw crop_gray((0,1,0,0),length/3,w,-xpart llcorner page, ypart llcorner page - d - 0length/3,w/20) ;
+ draw crop_gray((0,0,1,0),length/3,w,-xpart llcorner page, ypart llcorner page - d - 1length/3,w/20) ;
+
+ setbounds currentpicture to page ;
+
+enddef ;
+
+def page_marks_add_marking(expr width, height, length, offset) = % todo: namespace
+
+ path page ; page := fullsquare xscaled width yscaled height ;
+ path more ; more := page enlarged (offset+length/2,offset+length/2) ;
+
+ draw crop_marks_gray shifted center(topboundary more) shifted (0, offset+length);
+ draw crop_marks_cmyk shifted center(bottomboundary more) shifted (0,-offset-length);
+
+ setbounds currentpicture to page ;
+
+enddef ;
+
+def page_marks_add_lines(expr width, height, length, offset, nx, ny) = % todo: namespace
+
+ path page ; page := fullsquare xscaled width yscaled height ;
+ path more ; more := page enlarged (offset+length/2,offset+length/2) ;
+
+ draw crop_marks_lines(page,length,offset,nx,ny) ;
+
+ setbounds currentpicture to page ;
+
+enddef ;
+
+def page_marks_add_number(expr width, height, length, offset, n) = % todo: namespace
+
+ path page ; page := fullsquare xscaled width yscaled height ;
+ path more ; more := page enlarged (offset+length/2,offset+length/2) ;
+
+ for s=llcorner more, lrcorner more, ulcorner more, urcorner more :
+ draw textext(decimal n) shifted s ;
+ endfor ;
+
+ setbounds currentpicture to page ;
+
+enddef ;
diff --git a/metapost/context/base/mp-page.mpiv b/metapost/context/base/mp-page.mpiv
index ba6dcd6a5..bb8218be5 100644
--- a/metapost/context/base/mp-page.mpiv
+++ b/metapost/context/base/mp-page.mpiv
@@ -38,196 +38,6 @@ if unknown InPageBody :
InPageBody := false ;
fi ;
-def SaveTextAreas =
- path SavedTextAreas [] ;
- path SavedTextColumns[] ;
- numeric NOfSavedTextAreas ;
- numeric NOfSavedTextColumns ;
- for i=1 upto NOfTextAreas :
- SavedTextAreas[i] := TextAreas[i] ;
- endfor ;
- for i=1 upto NOfTextColumns :
- SavedTextColumns[i] := TextColumns[i] ;
- endfor ;
- NOfSavedTextAreas := NOfTextAreas ;
- NOfSavedTextColumns := NOfTextColumns ;
-enddef ;
-
-def ResetTextAreas =
- path TextAreas[], TextColumns[], PlainTextArea, RegionTextArea ;
- numeric NOfTextAreas ; NOfTextAreas := 0 ;
- numeric NOfTextColumns ; NOfTextColumns := 0 ;
- numeric nofmultipars ; nofmultipars := 0 ;
- TextAreas[0] := TextColumns[0] := origin -- cycle ;
-enddef ;
-
-ResetTextAreas ; SaveTextAreas ; ;
-
-def RegisterTextArea (expr x, y, w, h, d) =
- begingroup ;
- save p ; path p ;
- p := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
- if NOfTextAreas>0 :
- % if needed, concatenate areas
- if (round(llcorner TextAreas[NOfTextAreas]) = round(ulcorner p)) and
- (round(lrcorner TextAreas[NOfTextAreas]) = round(urcorner p)) :
- p :=
- ulcorner TextAreas[NOfTextAreas] --
- urcorner TextAreas[NOfTextAreas] --
- lrcorner p --
- llcorner p -- cycle ;
- else :
- NOfTextAreas := NOfTextAreas + 1 ;
- fi ;
- else :
- NOfTextAreas := NOfTextAreas + 1 ;
- fi ;
- TextAreas[NOfTextAreas] := p ;
- if NOfTextColumns>0 :
- if (round(xpart llcorner TextColumns[NOfTextColumns]) = round(xpart ulcorner p)) and
- (round(xpart lrcorner TextColumns[NOfTextColumns]) = round(xpart urcorner p)) :
- p :=
- ulcorner TextColumns[NOfTextColumns] --
- urcorner TextColumns[NOfTextColumns] --
- lrcorner p --
- llcorner p -- cycle ;
- else :
- NOfTextColumns := NOfTextColumns + 1 ;
- fi ;
- else :
- NOfTextColumns := NOfTextColumns + 1 ;
- fi ;
- TextColumns[NOfTextColumns] := p ;
- endgroup ;
-enddef ;
-
-%D We store a local area in slot zero.
-
-def RegisterPlainTextArea(expr x,y,w,h,d) =
- PlainTextArea := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
-enddef ;
-
-def RegisterRegionTextArea(expr x,y,w,h,d) =
- RegionTextArea := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
-% RegionTextArea := RegionTextArea enlarged 2mm ;
-enddef ;
-
-def RegisterLocalTextArea (expr x, y, w, h, d) =
- TextAreas[0] := TextColumns[0] := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
-enddef ;
-
-def ResetLocalTextArea =
- TextAreas[0] := TextColumns[0] := origin -- cycle ;
-enddef ;
-
-ResetLocalTextArea ;
-
-vardef InsideTextArea (expr _i_, _xy_) =
- (round(xpart _xy_) >= round(xpart llcorner TextAreas[_i_])) and
- (round(xpart _xy_) <= round(xpart lrcorner TextAreas[_i_])) and
- (round(ypart _xy_) >= round(ypart llcorner TextAreas[_i_])) and
- (round(ypart _xy_) <= round(ypart urcorner TextAreas[_i_]))
-enddef ;
-
-vardef InsideSavedTextArea (expr _i_, _xy_) =
- (round(xpart _xy_) >= round(xpart llcorner SavedTextAreas[_i_])) and
- (round(xpart _xy_) <= round(xpart lrcorner SavedTextAreas[_i_])) and
- (round(ypart _xy_) >= round(ypart llcorner SavedTextAreas[_i_])) and
- (round(ypart _xy_) <= round(ypart urcorner SavedTextAreas[_i_]))
-enddef ;
-
-vardef InsideSomeTextArea (expr _xy_) =
- save ok ; boolean ok ; ok := false ;
- for i := 1 upto NOfTextAreas :
- if InsideTextArea(i,_xy_) :
- ok := true ; % we can move the exit here
- fi ;
- exitif ok ;
- endfor ;
- ok
-enddef ;
-
-vardef InsideSomeSavedTextArea (expr _xy_) =
- save ok ; boolean ok ; ok := false ;
- for i := 1 upto NOfSavedTextAreas :
- if InsideSavedTextArea(i,_xy_) :
- ok := true ;
- fi ;
- exitif ok ;
- endfor ;
- ok
-enddef ;
-
-vardef TextAreaX (expr x) =
- numeric _TextAreaX_ ; _TextAreaX_ := 0 ;
- for i := 1 upto NOfTextAreas :
- if (round(x) >= round(xpart llcorner TextAreas[i])) and
- (round(x) <= round(xpart lrcorner TextAreas[i])) :
- _TextAreaX_ := xpart llcorner TextAreas[i] ;
- fi ;
- endfor ;
- _TextAreaX_
-enddef ;
-
-vardef TextAreaY (expr y) =
- numeric _TextAreaY_ ; _TextAreaY_ := 0 ;
- for i := 1 upto NOfTextAreas :
- if (round(y) >= round(ypart llcorner TextAreas[NOfTextAreas])) and
- (round(y) <= round(ypart ulcorner TextAreas[NOfTextAreas])) :
- _TextAreaY_ := ypart llcorner TextAreas[NOfTextAreas] ;
- fi ;
- endfor ;
- _TextAreaY_
-enddef ;
-
-vardef TextAreaXY (expr x, y) =
- pair _TextAreaXY_ ; _TextAreaXY_ := origin ;
- for i := 1 upto NOfTextAreas :
- if (round(x) >= round(xpart llcorner TextAreas[i])) and
- (round(x) <= round(xpart lrcorner TextAreas[i])) and
- (round(y) >= round(ypart llcorner TextAreas[i])) and
- (round(y) <= round(ypart ulcorner TextAreas[i])) :
- _TextAreaXY_ := llconer TextAreas[i] ;
- fi ;
- endfor ;
- _TextAreaXY_
-enddef ;
-
-vardef TextAreaW (expr x) =
- numeric _TextAreaW_ ; _TextAreaW_ := 0 ;
- for i := 1 upto NOfTextAreas :
- if (round(x) >= round(xpart llcorner TextAreas[i])) and
- (round(x) <= round(xpart lrcorner TextAreas[i])) :
- _TextAreaW_ := bbwidth(TextAreas[i]) ;
- fi ;
- endfor ;
- _TextAreaW_
-enddef ;
-
-vardef TextAreaH (expr y) =
- numeric _TextAreaH_ ; _TextAreaH_ := 0 ;
- for i := 1 upto NOfTextAreas :
- if (round(y) >= round(ypart llcorner TextAreas[i])) and
- (round(y) <= round(ypart ulcorner TextAreas[i])) :
- _TextAreaH_ := bbheight(TextAreas[i]) ;
- fi ;
- endfor ;
- _TextAreaH_
-enddef ;
-
-vardef TextAreaWH (expr x, y) =
- pair _TextAreaWH_ ; _TextAreaWH_ := origin ;
- for i := 1 upto NOfTextAreas :
- if (round(x) >= round(xpart llcorner TextAreas[i])) and
- (round(x) <= round(xpart lrcorner TextAreas[i])) and
- (round(y) >= round(ypart llcorner TextAreas[i])) and
- (round(y) <= round(ypart ulcorner TextAreas[i])) :
- _TextAreaWH_ := (bbwidth(TextAreas[i]),bbheight(TextAreas[i])) ;
- fi ;
- endfor ;
- _TextAreaWH_
-enddef ;
-
string CurrentLayout ;
CurrentLayout := "default" ;
@@ -510,210 +320,3 @@ def Enlarged (expr p, d) =
urEnlarged (p,d) --
ulEnlarged (p,d) -- cycle)
enddef ;
-
-% New:
-
-def position_anchor_bar(expr p_b_self, p_e_self, y_b_self, y_e_self, h_b_self, d_e_self,
- distance, linewidth, linecolor) =
- StartPage ;
- path p ; p :=
- if p_b_self=p_e_self :
- (xpart ulcorner Field[Text][Text],y_b_self+h_b_self) --
- (xpart llcorner Field[Text][Text],y_e_self-d_e_self) ;
- elseif RealPageNumber=p_b_self :
- (xpart ulcorner Field[Text][Text],y_b_self+h_b_self) --
- (llcorner Field[Text][Text]) ;
- elseif RealPageNumber=p_e_self :
- (ulcorner Field[Text][Text]) --
- (xpart llcorner Field[Text][Text],y_e_self-d_e_self) ;
- else :
- (ulcorner Field[Text][Text]) --
- (llcorner Field[Text][Text]) ;
- fi ;
- p := p shifted (-llcorner Field[Text][Text]-(distance,0)) ;
- interim linecap := butt ;
- draw p
- withpen pencircle scaled linewidth
- withcolor linecolor ;
- StopPage ;
-enddef ;
-
-% Crop stuff
-
-vardef crop_marks_lines (expr box, length, offset, nx, ny) =
- save p ; picture p ; save w, h, x, y ; numeric w, h, x, y ;
- p := image (
- x := if nx = 0 : 1 else : nx - 1 fi ;
- y := if ny = 0 : 1 else : ny - 1 fi ;
- w := bbwidth (box) / x ;
- h := bbheight(box) / y ;
- for i=0 upto y :
- draw ((llcorner box) -- (llcorner box) shifted (-length,0)) shifted (-offset,i*h) ;
- draw ((lrcorner box) -- (lrcorner box) shifted ( length,0)) shifted ( offset,i*h) ;
- endfor ;
- for i=0 upto x :
- draw ((llcorner box) -- (llcorner box) shifted (0,-length)) shifted (i*w,-offset) ;
- draw ((ulcorner box) -- (ulcorner box) shifted (0, length)) shifted (i*w, offset) ;
- endfor ;
- ) ;
- setbounds p to box ;
- p
-enddef ;
-
-vardef crop_marks_cmyk =
- save p ; picture p ; p := image (
- fill ulcircle scaled 12.5 withcolor (1,0,0,0) ;
- fill urcircle scaled 12.5 withcolor (0,1,0,0) ;
- fill lrcircle scaled 12.5 withcolor (0,0,1,0) ;
- fill llcircle scaled 12.5 withcolor (0,0,0,1) ;
- draw (-10,0) -- (10,0) ;
- draw (0,-10) -- (0,10) ;
- draw fullcircle scaled 12.5 ;
- ) ;
- setbounds p to fullsquare scaled 20 ;
- p
-enddef ;
-
-vardef crop_marks_gray =
- save p ; picture p ; p := image (
- fill ulcircle scaled 12.5 withcolor (0.00) ;
- fill urcircle scaled 12.5 withcolor (0.25) ;
- fill lrcircle scaled 12.5 withcolor (0.50) ;
- fill llcircle scaled 12.5 withcolor (0.75) ;
- draw (-10,0) -- (10,0) ;
- draw (0,-10) -- (0,10) ;
- draw (-6,0) -- (6,0) withcolor white ;
- draw (0,-6) -- (0,6) withcolor white ;
- draw fullcircle scaled 12.5 ;
- ) ;
- setbounds p to fullsquare scaled 20 ;
- p
-enddef ;
-
-vardef crop_marks_cmykrgb =
- save p ; picture p ; p := image (
- fill ulcircle scaled 15 withcolor (1,0,0) ;
- fill urcircle scaled 15 withcolor (0,1,0) ;
- fill lrcircle scaled 15 withcolor (0,0,1) ;
- fill llcircle scaled 15 withcolor (.5,.5,.5) ;
- fill ulcircle scaled 10 withcolor (1,0,0,0) ;
- fill urcircle scaled 10 withcolor (0,1,0,0) ;
- fill lrcircle scaled 10 withcolor (0,0,1,0) ;
- fill llcircle scaled 10 withcolor (0,0,0,1) ;
- draw (-10,0) -- (10,0) ;
- draw (0,-10) -- (0,10) ;
- draw fullcircle scaled 10 ;
- draw fullcircle scaled 15 ;
- ) ;
- setbounds p to fullsquare scaled 20 ;
- p
-enddef ;
-
-vardef crop_color(expr c, h, w, dx, dy, ts) =
- image (
- save p ; path p ;
- for i=1 upto 6 :
- p := fullsquare
- xscaled w
- yscaled h
- shifted (dx,dy-i*h) ;
- fill p
- withcolor (crop_colors[i]*c) ;
- draw textext("\format{'@0.2f'," & decimal crop_colors[i] & "}")
- scaled ts
- shifted center p withcolor white ;
- endfor ;
- )
-enddef ;
-
-vardef crop_gray(expr c, h, w, dx, dy, ts) =
- image (
- save p ; path p ;
- for i=.05 step .05 until 1 :
- p := fullsquare
- xscaled w
- yscaled h
- shifted (20*(i-1)*w+dx,dy) ;
- fill p
- withcolor (i*c) ;
- draw textext("\format{'@0.2f'," & decimal i & "}")
- scaled ts
- shifted center p withcolor white ;
- endfor ;
- )
-enddef ;
-
-% draw crop_marks_cmyk shifted llcorner more ;
-% draw crop_marks_cmyk shifted lrcorner more ;
-% draw crop_marks_cmyk shifted ulcorner more ;
-% draw crop_marks_cmyk shifted urcorner more ;
-
-def page_marks_add_color(expr width, height, length, offset) = % todo: namespace
-
- path page ; page := fullsquare xscaled width yscaled height ;
- path more ; more := page enlarged (offset+length/2,offset+length/2) ;
-
- numeric crop_colors[] ;
- crop_colors[1] := 1 ;
- crop_colors[2] := 0.95 ;
- crop_colors[3] := 0.75 ;
- crop_colors[4] := 0.50 ;
- crop_colors[5] := 0.25 ;
- crop_colors[6] := 0.05 ;
-
- numeric h ; h := height / 20 ;
- numeric w ; w := width / 20 ;
- numeric d ; d := offset + length/2 ;
-
- draw crop_color((1,0,0,0),h,length,xpart ulcorner page - d, 10h,length/20) ;
- draw crop_color((0,1,0,0),h,length,xpart ulcorner page - d,3.5h,length/20) ;
- draw crop_color((0,0,1,0),h,length,xpart ulcorner page - d, -3h,length/20) ;
-
- draw crop_color((0,1,1,0),h,length,xpart urcorner page + d, 10h,length/20) ;
- draw crop_color((1,0,1,0),h,length,xpart urcorner page + d,3.5h,length/20) ;
- draw crop_color((1,1,0,0),h,length,xpart urcorner page + d, -3h,length/20) ;
-
- draw crop_gray((0,0,0,1),length, w,-xpart llcorner page,-ypart llcorner page + d ,w/20) ;
- draw crop_gray((1,0,0,0),length/3,w,-xpart llcorner page, ypart llcorner page - d + 1length/3,w/20) ;
- draw crop_gray((0,1,0,0),length/3,w,-xpart llcorner page, ypart llcorner page - d - 0length/3,w/20) ;
- draw crop_gray((0,0,1,0),length/3,w,-xpart llcorner page, ypart llcorner page - d - 1length/3,w/20) ;
-
- setbounds currentpicture to page ;
-
-enddef ;
-
-def page_marks_add_marking(expr width, height, length, offset) = % todo: namespace
-
- path page ; page := fullsquare xscaled width yscaled height ;
- path more ; more := page enlarged (offset+length/2,offset+length/2) ;
-
- draw crop_marks_gray shifted center(topboundary more) shifted (0, offset+length);
- draw crop_marks_cmyk shifted center(bottomboundary more) shifted (0,-offset-length);
-
- setbounds currentpicture to page ;
-
-enddef ;
-
-def page_marks_add_lines(expr width, height, length, offset, nx, ny) = % todo: namespace
-
- path page ; page := fullsquare xscaled width yscaled height ;
- path more ; more := page enlarged (offset+length/2,offset+length/2) ;
-
- draw crop_marks_lines(page,length,offset,nx,ny) ;
-
- setbounds currentpicture to page ;
-
-enddef ;
-
-def page_marks_add_number(expr width, height, length, offset, n) = % todo: namespace
-
- path page ; page := fullsquare xscaled width yscaled height ;
- path more ; more := page enlarged (offset+length/2,offset+length/2) ;
-
- for s=llcorner more, lrcorner more, ulcorner more, urcorner more :
- draw textext(decimal n) shifted s ;
- endfor ;
-
- setbounds currentpicture to page ;
-
-enddef ;
diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv
index 30c8f1cd6..c66a78a2c 100644
--- a/metapost/context/base/mp-tool.mpiv
+++ b/metapost/context/base/mp-tool.mpiv
@@ -1233,7 +1233,7 @@ vardef freelabel (expr str, loc, ori) =
enddef ;
vardef freedotlabel (expr str, loc, ori) =
- interim linecap:=rounded ;
+ interim linecap := rounded ;
draw loc withpen pencircle scaled freedotlabelsize ;
draw thefreelabel(str,loc,ori) ;
enddef ;