summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/context/base/mpiv/mp-mlib.mpiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/metapost/context/base/mpiv/mp-mlib.mpiv')
-rw-r--r--Master/texmf-dist/metapost/context/base/mpiv/mp-mlib.mpiv485
1 files changed, 200 insertions, 285 deletions
diff --git a/Master/texmf-dist/metapost/context/base/mpiv/mp-mlib.mpiv b/Master/texmf-dist/metapost/context/base/mpiv/mp-mlib.mpiv
index 1317967570d..115fe63aeac 100644
--- a/Master/texmf-dist/metapost/context/base/mpiv/mp-mlib.mpiv
+++ b/Master/texmf-dist/metapost/context/base/mpiv/mp-mlib.mpiv
@@ -16,18 +16,6 @@ if known context_mlib : endinput ; fi ;
boolean context_mlib ; context_mlib := true ;
-numeric LUATEXFUNCTIONALITY ; LUATEXFUNCTIONALITY := runscript("mp.print(LUATEXFUNCTIONALITY)") ;
-
-%D Objects:
-
-vardef isobject expr p =
- if picture p :
- lua.mp.isobject(prescriptpart p)
- else :
- false
- fi
-enddef ;
-
%D Color and transparency
%D
%D Separable:
@@ -72,16 +60,16 @@ def namedcolor expr n =
withprescript "sp_name=" & n
enddef ;
-% def mfun_spotcolor(expr n, v) =
+% def spotcolor(expr n, v) =
% 1
-% withprescript "sp_type=xspot"
+% withprescript "sp_type=spot"
% withprescript "sp_name=" & n
% withprescript "sp_value=" & (if numeric v : decimal v else : v fi)
% enddef ;
-
-% def mfun_multispotcolor(expr name, fractions, components, value) =
+%
+% def multitonecolor(expr name, fractions, components, value) =
% 1
-% withprescript "sp_type=multispot"
+% withprescript "sp_type=multitone"
% withprescript "sp_name=" & name
% withprescript "sp_fractions=" & decimal fractions
% withprescript "sp_components=" & components
@@ -91,12 +79,10 @@ enddef ;
def spotcolor(expr name, v) =
(1)
withprescript "sp_type=spot"
- withprescript "sp_name=" & name
+ withprescript "sp_name=" & name
withprescript "sp_value=" & colordecimals v
enddef ;
-% In this case a mixed color will be calculated:
-
def multitonecolor(expr name)(text t) =
(1)
withprescript "sp_type=multitone"
@@ -106,7 +92,7 @@ enddef ;
def transparent(expr a, t)(text c) = % use withtransparency instead
(1) % this permits withcolor x intoshade y
- withprescript "tr_alternative=" & decimal transparency_alternative_to_number(a)
+ withprescript "tr_alternative=" & decimal transparency_alternative_to_number(a)
withprescript "tr_transparency=" & decimal t
withcolor c
enddef ;
@@ -188,52 +174,72 @@ extra_beginfig := extra_beginfig & "mfun_reset_tex_texts ;" ;
% flush twice: once in location in order to pick up e.g. color properties,
% and once at the end because we need to flush missing ones.
-boolean mfun_onetime_textext ; mfun_onetime_textext := false ;
-
-def notcached = withprescript "tx_cache=no" enddef ;
+% see mp-keep.mpiv for older code
-% todo: onetime
+% vardef rawtextext(expr s) = % todo: avoid currentpicture
+% if s = "" :
+% nullpicture
+% else :
+% mfun_tt_n := mfun_tt_n + 1 ;
+% mfun_tt_c := nullpicture ;
+% if mfun_trial_run :
+% mfun_tt_o := nullpicture ;
+% addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
+% addto mfun_tt_c doublepath unitsquare
+% withprescript "tx_number=" & decimal mfun_tt_n
+% withprescript "tx_stage=trial"
+% withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
+% withpostscript s ;
+% addto mfun_tt_p also mfun_tt_c ;
+% elseif known mfun_tt_d[mfun_tt_n] :
+% addto mfun_tt_c doublepath unitsquare
+% xscaled mfun_tt_w[mfun_tt_n]
+% yscaled (mfun_tt_h[mfun_tt_n] + mfun_tt_d[mfun_tt_n])
+% shifted (0,-mfun_tt_d[mfun_tt_n])
+% withprescript "tx_number=" & decimal mfun_tt_n
+% withprescript "tx_stage=final" ;
+% else :
+% addto mfun_tt_c doublepath unitsquare ; % unitpicture
+% fi ;
+% mfun_tt_c
+% fi
+% enddef ;
-rgbcolor mfun_tt_r ;
+boolean mfun_onetime_textext ; mfun_onetime_textext := false ;
-vardef rawtextext(expr s) =
+vardef rawtextext(expr s) = % todo: avoid currentpicture
if s = "" :
+ mfun_onetime_textext := false ;
nullpicture
else :
mfun_tt_n := mfun_tt_n + 1 ;
mfun_tt_c := nullpicture ;
- mfun_tt_o := nullpicture ;
- addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- mfun_tt_r := lua.mp.mf_some_text(mfun_tt_n,s) ;
- addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_r
- yscaled (htpart mfun_tt_r + dppart mfun_tt_r)
- shifted (0,-dppart mfun_tt_r)
- withprescript "mf_object=text"
- withprescript "tx_index=" & decimal mfun_tt_n
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- ;
+ if mfun_trial_run :
+ mfun_tt_o := nullpicture ;
+ addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
+ addto mfun_tt_c doublepath unitsquare
+ withprescript "tx_number=" & decimal mfun_tt_n
+ withprescript "tx_stage=trial"
+ withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
+ withpostscript s ;
+ if not mfun_onetime_textext :
+ addto mfun_tt_p also mfun_tt_c
+ withprescript "tx_global=yes" ;
+ fi ;
+ else :
+ mfun_tt_b := lua.mp.tt_dimensions(mfun_tt_n) ;
+ addto mfun_tt_c doublepath unitsquare
+ xscaled redpart mfun_tt_b
+ yscaled (greenpart mfun_tt_b + bluepart mfun_tt_b)
+ shifted (0,- bluepart mfun_tt_b)
+ withprescript "tx_number=" & decimal mfun_tt_n
+ withprescript "tx_stage=final" ;
+ fi ;
+ mfun_onetime_textext := false ;
mfun_tt_c
fi
enddef ;
-vardef rawmadetext =
- mfun_tt_n := mfun_tt_n + 1 ;
- mfun_tt_c := nullpicture ;
- mfun_tt_o := nullpicture ;
- addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- mfun_tt_r := lua.mp.mf_made_text(mfun_tt_n) ;
- addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_r
- yscaled (htpart mfun_tt_r + dppart mfun_tt_r)
- shifted (0,-dppart mfun_tt_r)
- withprescript "mf_object=text"
- withprescript "tx_index=" & decimal mfun_tt_n
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- ;
- mfun_tt_c
-enddef ;
-
vardef validtexbox(expr category, name) =
if category == "" :
false
@@ -249,12 +255,11 @@ enddef ;
vardef rawtexbox(expr category, name) =
mfun_tt_c := nullpicture ;
if validtexbox(category,name) :
- mfun_tt_b := lua.mp.mf_tb_dimensions(category, name) ;
+ mfun_tt_b := lua.mp.tb_dimensions(category, name) ;
addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_b
- yscaled (htpart mfun_tt_b + dppart mfun_tt_b)
- shifted (0,- dppart mfun_tt_b)
- withprescript "mf_object=box"
+ xscaled redpart mfun_tt_b
+ yscaled (greenpart mfun_tt_b + bluepart mfun_tt_b)
+ shifted (0,- bluepart mfun_tt_b)
withprescript "bx_category=" & if numeric category : decimal fi category
withprescript "bx_name=" & if numeric name : decimal fi name ;
fi
@@ -363,25 +368,13 @@ vardef installlabel@# (expr type, x, y, offset) =
numeric labyf @# ; labyf @# := y ;
enddef ;
-vardef mfun_labshift@#(expr p) =
- (mfun_labxf@#*lrcorner p +
- mfun_labyf@#*ulcorner p +
- (1-mfun_labxf@#-mfun_labyf@#)*llcorner p)
-enddef ;
-
-vardef mfun_picshift@#(expr p) =
- (mfun_labxf@#*ulcorner p +
- mfun_labyf@#*lrcorner p +
- (1-mfun_labxf@#-mfun_labyf@#)*urcorner p)
-enddef ;
-
% we save the plain variant
vardef plain_thelabel@#(expr p,z) =
if string p :
plain_thelabel@#(rawtextext("\definedfont[" & defaultfont & "]" & p) scaled defaultscale,z)
else :
- p shifted (z + labeloffset*laboff@# - mfun_labshift@#(p))
+ p shifted (z + labeloffset*laboff@# - (labxf@#*lrcorner p + labyf@#*ulcorner p + (1-labxf@#-labyf@#)*llcorner p))
fi
enddef;
@@ -410,22 +403,7 @@ enddef ;
plain_compatibility_data := plain_compatibility_data & "save label, thelabel ;" & "useplainlabels ;" ;
-% vardef thetextext@#(expr p,z) =
-% % interim labeloffset := textextoffset ;
-% if string p :
-% thetextext@#(rawtextext(p),z)
-% elseif numeric p :
-% thetextext@#(rawtextext(decimal p),z)
-% else :
-% p
-% if (mfun_labtype@# >= 10) :
-% shifted (0,ypart center p)
-% fi
-% shifted (z + textextoffset*mfun_laboff@# - mfun_labshift@#(p))
-% fi
-% enddef ;
-
-newinternal anchortextexts ; anchortextexts := 0 ; % disabled by default
+% next comes own own:
vardef thetextext@#(expr p,z) =
% interim labeloffset := textextoffset ;
@@ -433,18 +411,12 @@ vardef thetextext@#(expr p,z) =
thetextext@#(rawtextext(p),z)
elseif numeric p :
thetextext@#(rawtextext(decimal p),z)
- elseif pair p :
- thetextext@#(rawtextext(ddecimal p),z)
else :
- if anchortextexts > 0 :
- image(draw p withprescript "tx_anchor=" & ddecimal z)
- else :
- p
- fi
- if (mfun_labtype@# >= 10) :
- shifted (0,ypart center p)
- fi
- shifted (z + textextoffset*mfun_laboff@# - mfun_labshift@#(p))
+ p
+ if (mfun_labtype@# >= 10) :
+ shifted (0,ypart center p)
+ fi
+ shifted (z + textextoffset*mfun_laboff@# - (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
fi
enddef ;
@@ -461,38 +433,56 @@ enddef ;
pair mfun_tt_z ;
-vardef rawfmttext(text t) =
+vardef rawfmttext(text t) = % todo: avoid currentpicture
mfun_tt_n := mfun_tt_n + 1 ;
mfun_tt_c := nullpicture ;
- mfun_tt_o := nullpicture ;
- addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- mfun_tt_r := lua.mp.mf_formatted_text(mfun_tt_n,t) ;
- addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_r
- yscaled (htpart mfun_tt_r + dppart mfun_tt_r)
- shifted (0,-dppart mfun_tt_r)
- withprescript "mf_object=text"
- withprescript "tx_index=" & decimal mfun_tt_n
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- ;
- for s = t :
- if pair s : mfun_tt_z := s ; fi
- endfor ;
+ if mfun_trial_run :
+ mfun_tt_o := nullpicture ;
+ addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
+ addto mfun_tt_c doublepath unitsquare
+ withprescript "tx_number=" & decimal mfun_tt_n
+ withprescript "tx_stage=trial"
+ withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
+ % begin of fmt specific
+ withprescript "tx_type=format"
+ for s = t :
+ if string s : withpostscript "s:" & s
+ elseif numeric s : withpostscript "n:" & decimal s
+ elseif boolean s : withpostscript "b:" & if s : "true" else : "false" fi
+ elseif pair s : hide(mfun_tt_z := s ; )
+ fi
+ endfor ;
+ % end of fmt specific
+ if not mfun_onetime_textext :
+ addto mfun_tt_p also mfun_tt_c
+ withprescript "tx_global=yes" ;
+ fi ;
+ else :
+ mfun_tt_b := lua.mp.tt_dimensions(mfun_tt_n) ;
+ addto mfun_tt_c doublepath unitsquare
+ xscaled redpart mfun_tt_b
+ yscaled (greenpart mfun_tt_b + bluepart mfun_tt_b)
+ shifted (0,- bluepart mfun_tt_b)
+ withprescript "tx_number=" & decimal mfun_tt_n
+ withprescript "tx_stage=final" ;
+ % begin of fmt specific
+ for s = t :
+ if pair s : mfun_tt_z := s ; fi
+ endfor ;
+ % end of fmt specific
+ fi ;
+ mfun_onetime_textext := false ;
mfun_tt_c
enddef ;
vardef thefmttext@#(text t) =
- mfun_tt_z := origin ; % initialization
+ mfun_tt_z := origin ;
save p ; picture p ; p := rawfmttext(t) ;
- if anchortextexts > 0 :
- image(draw p withprescript "tx_anchor=" & ddecimal mfun_tt_z)
- else :
- p
- fi
+ p
if (mfun_labtype@# >= 10) :
shifted (0,ypart center p)
fi
- shifted (mfun_tt_z + textextoffset*mfun_laboff@# - mfun_labshift@#(p))
+ shifted (mfun_tt_z + textextoffset*mfun_laboff@# - (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
enddef ;
vardef fmttext@#(text t) = % no draw here
@@ -514,44 +504,18 @@ vardef thetexbox@#(expr category, name, z) =
if (mfun_labtype@# >= 10) :
shifted (0,ypart center p)
fi
- shifted (z + textextoffset*mfun_laboff@# - mfun_labshift@#(p))
+ shifted (z + textextoffset*mfun_laboff@# - (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
enddef ;
vardef texbox@#(expr category, name) = % no draw here
thetexbox@#(category,name,origin)
enddef ;
-% vardef thelabel@#(expr p,z) =
-% if string p :
-% thelabel@#(rawtextext("\definedfont[" & defaultfont & "]" & p) scaled defaultscale,z)
-% else :
-% p shifted (z + labeloffset*mfun_laboff@# - (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
-% fi
-% enddef;
-
-vardef theoffset@#(expr z) =
- if pair z :
- z
- elseif path z :
- if mfun_laboff@# = origin :
- center z
- else :
- ((center z)-- mfun_picshift@#(z)) intersectionpoint (z if not cycle z: --cycle fi)
- fi
- else : % picture
- mfun_picshift@#(z)
- fi
-enddef;
-
vardef thelabel@#(expr p,z) =
if string p :
thelabel@#(rawtextext("\definedfont[" & defaultfont & "]" & p) scaled defaultscale,z)
- elseif numeric p :
- thelabel@#(decimal p,z)
- elseif pair p :
- thelabel@#("(" & decimal(xpart p) & "," & decimal(ypart p) & ")",z)
else :
- p shifted (theoffset@#(z) + labeloffset*mfun_laboff@# - mfun_labshift@#(p))
+ p shifted (z + labeloffset*mfun_laboff@# - (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
fi
enddef;
@@ -564,7 +528,7 @@ vardef anchored@#(expr p, z) = % beware: no "+ mfun_laboff@#" here (never!)
if (mfun_labtype@# >= 10) :
shifted (0,ypart center p)
fi
- shifted (z + mfun_labshift@#(p))
+ shifted (z + (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
enddef ;
let normalinfont = infont ;
@@ -1020,16 +984,18 @@ def withmask primary filename =
withprescript "fg_mask=" & filename
enddef ;
-vardef externalfigure primary filename =
- mfun_tt_c := nullpicture ;
- mfun_tt_r := lua.mp.mf_external_figure(filename) ;
- addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_r
- yscaled htpart mfun_tt_r
- withprescript "mf_object=figure"
- withprescript "fg_name=" & filename ;
- ;
- mfun_tt_c
+def externalfigure primary filename =
+ if false :
+ rawtextext("\externalfigure[" & filename & "]")
+ else :
+ image (
+ addto currentpicture doublepath unitsquare
+ withprescript "fg_name=" & filename ;
+ )
+% unitsquare
+% withpen pencircle scaled 0
+% withprescript "fg_name=" & filename
+ fi
enddef ;
def figure primary filename =
@@ -1049,85 +1015,101 @@ enddef ;
numeric currentoutlinetext ; currentoutlinetext := 0 ;
-vardef mfun_do_outline_text_flush (expr kind, n, x, y, c) (text t) =
+vardef mfun_do_outline_text_flush (expr kind, n, x, y) (text t) =
if kind = "f" :
- mfun_do_outline_text_f (n, x, y, c) (t)
+ mfun_do_outline_text_f (n, x, y) (t)
elseif kind = "d" :
- mfun_do_outline_text_d (n, x, y, c) (t)
+ mfun_do_outline_text_d (n, x, y) (t)
elseif kind = "b" :
- mfun_do_outline_text_b (n, x, y, c) (t)
+ mfun_do_outline_text_b (n, x, y) (t)
elseif kind = "r" :
- mfun_do_outline_text_r (n, x, y, c) (t)
+ mfun_do_outline_text_r (n, x, y) (t)
elseif kind = "p" :
- mfun_do_outline_text_p (n, x, y, c) (t)
+ mfun_do_outline_text_p (n, x, y) (t)
elseif kind = "u" :
- mfun_do_outline_text_u (n, x, y, c) (t)
+ mfun_do_outline_text_u (n, x, y) (t)
else :
- mfun_do_outline_text_n (n, x, y, c) (t)
+ mfun_do_outline_text_n (n, x, y) (t)
fi ;
enddef ;
vardef mfun_do_outline_rule_flush (expr kind, x, y, w, h) =
- mfun_do_outline_text_flush (kind, 1, x, y, "") (fullsquare xyscaled(w,h))
+ mfun_do_outline_text_flush (kind, 1, x, y) (fullsquare xyscaled(w,h))
enddef ;
numeric mfun_do_outline_n ; mfun_do_outline_n := 0 ;
-vardef mfun_do_outline_text_f (expr n, x, y, c) (text t) =
+vardef mfun_do_outline_text_f (expr n, x, y) (text t) =
mfun_do_outline_n := 0 ;
for i=t :
mfun_do_outline_n := mfun_do_outline_n + 1 ;
- if mfun_do_outline_n = n : fill else : nofill fi (i shifted(x,y)) mfun_do_outline_options_f withpen pencircle scaled 0 withprescript c ;
+ if mfun_do_outline_n = n :
+ fill i shifted(x,y) mfun_do_outline_options_f withpen pencircle scaled 0
+ else :
+ nofill i shifted(x,y)
+ fi ;
endfor ;
enddef ;
-vardef mfun_do_outline_text_u (expr n, x, y, c) (text t) =
+vardef mfun_do_outline_text_u (expr n, x, y) (text t) =
mfun_do_outline_n := 0 ;
for i=t :
mfun_do_outline_n := mfun_do_outline_n + 1 ;
- if mfun_do_outline_n = n : fillup else : nofill fi (i shifted(x,y)) mfun_do_outline_options_f withprescript c ;
+ if mfun_do_outline_n = n :
+ fillup i shifted(x,y) mfun_do_outline_options_f
+ else :
+ nofill i shifted(x,y)
+ fi ;
endfor ;
enddef ;
-vardef mfun_do_outline_text_d (expr n, x, y, c) (text t) =
+vardef mfun_do_outline_text_d (expr n, x, y) (text t) =
for i=t :
draw i shifted(x,y) mfun_do_outline_options_d ;
endfor ;
enddef ;
-vardef mfun_do_outline_text_p (expr n, x, y, c) (text t) =
+vardef mfun_do_outline_text_p (expr n, x, y) (text t) =
for i=t :
- draw i shifted(x,y) withprescript c ;
+ draw i shifted(x,y) ;
endfor ;
enddef ;
-vardef mfun_do_outline_text_b (expr n, x, y, c) (text t) =
+vardef mfun_do_outline_text_b (expr n, x, y) (text t) =
mfun_do_outline_n := 0 ;
for i=t :
mfun_do_outline_n := mfun_do_outline_n + 1 ;
- if mfun_do_outline_n = n : fill else : nofill fi (i shifted(x,y)) mfun_do_outline_options_f ;
+ if mfun_do_outline_n = n :
+ fill i shifted(x,y) mfun_do_outline_options_f
+ else :
+ nofill i shifted(x,y)
+ fi ;
endfor ;
for i=t :
draw i shifted(x,y) mfun_do_outline_options_d ;
endfor ;
enddef ;
-vardef mfun_do_outline_text_r (expr n, x, y, c) (text t) =
+vardef mfun_do_outline_text_r (expr n, x, y) (text t) =
mfun_do_outline_n := 0 ;
for i=t :
draw i shifted(x,y) mfun_do_outline_options_d ;
endfor ;
for i=t :
mfun_do_outline_n := mfun_do_outline_n + 1 ;
- if mfun_do_outline_n = n : fill else : nofill fi (i shifted(x,y)) mfun_do_outline_options_f;
+ if mfun_do_outline_n = n :
+ fill i shifted(x,y) mfun_do_outline_options_f
+ else :
+ nofill i shifted(x,y)
+ fi ;
endfor ;
enddef ;
-vardef mfun_do_outline_text_n (expr n, x, y, c) (text t) =
+vardef mfun_do_outline_text_n (expr n, x, y) (text t) =
mfun_do_outline_n := 0 ;
for i=t :
mfun_do_outline_n := mfun_do_outline_n + 1 ;
- if mfun_do_outline_n = n : fill else : nofill fi (i shifted(x,y)) ;
+ if mfun_do_outline_n = n : fill else : nofill fi i shifted(x,y) ;
endfor ;
enddef ;
@@ -1164,39 +1146,6 @@ def mfun_do_outline_options_d = enddef ;
def mfun_do_outline_options_f = enddef ;
def mfun_do_outline_options_r = enddef ;
-def outlinetexttopath(text o, p, n) =
- scantokens("numeric " & str n & ";") ;
- scantokens("path " & str p & "[];") ;
- n := 0 ;
- for i within o : p[incr(n)] := pathpart i ; endfor ;
-enddef ;
-
-def filloutlinetext(expr o) =
- draw image (
- save n, m ; numeric n, m ; n := m := 0 ;
- for i within o :
- n := n + 1 ;
- endfor ;
- for i within o :
- m := m + 1 ;
- if n = m :
- eofill
- else :
- nofill
- fi pathpart i ;
- endfor ;
- )
-enddef ;
-
-def drawoutlinetext(expr o) =
- draw image (
- % nicer for properties
- for i within o :
- draw pathpart i ;
- endfor ;
- )
-enddef ;
-
vardef outlinetext@# (expr t) text rest =
save kind ; string kind ; kind := str @# ;
currentoutlinetext := currentoutlinetext + 1 ;
@@ -1204,25 +1153,32 @@ vardef outlinetext@# (expr t) text rest =
def mfun_do_outline_options_f = enddef ;
def mfun_do_outline_options_r = enddef ;
image ( normaldraw image (
- % lua.mp.report("set outline text",currentoutlinetext);
- lua.mp.mf_outline_text(currentoutlinetext,t,kind) ;
- % lua.mp.report("get outline text",currentoutlinetext);
- if kind = "f" :
- mfun_do_outline_text_set_f rest ;
- elseif kind = "d" :
- mfun_do_outline_text_set_d rest ;
- elseif kind = "b" :
- mfun_do_outline_text_set_b rest ;
- elseif kind = "u" :
- mfun_do_outline_text_set_f rest ;
- elseif kind = "r" :
- mfun_do_outline_text_set_r rest ;
- elseif kind = "p" :
- mfun_do_outline_text_set_p ;
+ if mfun_trial_run :
+ % lua.mp.report("set outline text",currentoutlinetext);
+ normaldraw unitsquare
+ withprescript "ot_stage=trial"
+ withprescript "ot_index=" & decimal currentoutlinetext
+ withprescript "ot_kind=" & kind
+ withpostscript t ;
else :
- mfun_do_outline_text_set_n rest ;
+ % lua.mp.report("get outline text",currentoutlinetext);
+ if kind = "f" :
+ mfun_do_outline_text_set_f rest ;
+ elseif kind = "d" :
+ mfun_do_outline_text_set_d rest ;
+ elseif kind = "b" :
+ mfun_do_outline_text_set_b rest ;
+ elseif kind = "u" :
+ mfun_do_outline_text_set_f rest ;
+ elseif kind = "r" :
+ mfun_do_outline_text_set_r rest ;
+ elseif kind = "p" :
+ mfun_do_outline_text_set_p ;
+ else :
+ mfun_do_outline_text_set_n rest ;
+ fi ;
+ lua.mp.get_outline_text(currentoutlinetext) ;
fi ;
- lua.mp.mf_get_outline_text(currentoutlinetext) ;
) mfun_do_outline_options_r ; )
enddef ;
@@ -1253,6 +1209,7 @@ vardef rule(expr wd,ht,dp) =
image (fill (0,-dp)--(wd,-dp)--(wd,ht)--(0,ht)--cycle)
enddef ;
+
% Housekeeping
extra_beginfig := extra_beginfig & "currentgraphictext := 0 ; " ;
@@ -1297,9 +1254,9 @@ def withproperties expr p =
withcolor (cyanpart p,magentapart p,yellowpart p,blackpart p)
fi
withpen penpart p
- if length (dashpart p) > 0 :
+ % if dashpart p <> nullpicture : % fails
dashed dashpart p
- fi
+ % fi
withprescript prescriptpart p
withpostscript postscriptpart p
enddef ;
@@ -1400,42 +1357,7 @@ vardef mfun_cmykcolor_to_string(expr c) =
decimal blackpart c
enddef ;
-vardef mfun_pair_to_table(expr p) =
- "{" & decimal xpart p &
- "," & decimal ypart p &
- "}"
-enddef ;
-
-vardef mfun_point_to_table(expr p,i) =
- "{" & decimal xpart (point i of p) &
- "," & decimal ypart (point i of p) &
- "," & decimal xpart (precontrol i of p) &
- "," & decimal ypart (precontrol i of p) &
- "," & decimal xpart (postcontrol i of p) &
- "," & decimal ypart (postcontrol i of p) &
- "}"
-enddef ;
-
-vardef mfun_path_to_table(expr p) =
- "{" & mfun_point_to_table(p,0) for i=1 upto length(p) : & "," & mfun_point_to_table(p,i) endfor & "}"
-enddef ;
-
-vardef mfun_rgb_to_table(expr c) =
- "{" & decimal redpart c &
- "," & decimal greenpart c &
- "," & decimal bluepart c &
- "}"
-enddef ;
-
-vardef mfun_cmyk_to_table(expr c) =
- "{" & decimal cyanpart c &
- "," & decimal magentapart c &
- "," & decimal yellowpart c &
- "," & decimal blackpart c &
- "}"
-enddef ;
-
-vardef mfun_grey_to_string(expr n) =
+vardef mfun_greycolor_to_string(expr n) =
decimal n
enddef ;
@@ -1646,8 +1568,8 @@ enddef ;
vardef strfmt(expr f, x) = "\MPgraphformat{" & escaped_format(f) & "}{" & mfun_tagged_string(x) & "}" enddef ;
vardef varfmt(expr f, x) = "\MPformatted{" & escaped_format(f) & "}{" & mfun_tagged_string(x) & "}" enddef ;
-vardef format@# (expr f, x) = textext@#(strfmt(f, x)) enddef ;
-vardef formatted@#(expr f, x) = textext@#(varfmt(f, x)) enddef ;
+vardef format (expr f, x) = textext(strfmt(f, x)) enddef ;
+vardef formatted(expr f, x) = textext(varfmt(f, x)) enddef ;
% could be this (something to discuss with alan as it involves graph):
%
@@ -1674,15 +1596,12 @@ def nofill text t = fill t withpostscript "collect" enddef ;
% so we can do: withcolor "red"
-% We do a low level runscript:
-%
-% lua.mp.namedcolor(s) % conflicts with macro namedcolor
-% lua.mp.mf_named_color(s) % okay but, can also be
-% lua.mp("mf_named_color",s) % which gives expansion mess
-
-def resolvedcolor primary s = % no vardef
+vardef resolvedcolor primary s =
+ % lua.mp.namedcolor(s) % conflicts with macro namedcolor
+ % lua.mp.NamedColor(s) % okay but, can also be
+ % lua.mp("NamedColor",s) % which gives expansion mess
if string s :
- runscript("mp.mf_named_color('" & s & "')") % faster anyway
+ runscript("mp.NamedColor('" & s & "')") % faster anyway
else :
s
fi
@@ -1695,10 +1614,6 @@ def comment expr str =
special "metapost.comment[[" & str & "]]" ;
enddef ;
-vardef report(text t) =
- lua.mp.report(t)
-enddef ;
-
% This overloads a dummy:
vardef uniquelist(suffix list) =