summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-06-08 10:23:49 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-06-08 10:23:49 +0200
commit86bfea5faac983d15c47eec27f43ec56e75c69ef (patch)
tree69a37851a9b8beeb625110f4fc51ff1ef188d7e4 /metapost
parentc2d2236242c95f4753e7b197d576102c6fc20446 (diff)
downloadcontext-86bfea5faac983d15c47eec27f43ec56e75c69ef.tar.gz
2018-06-08 09:38:00
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mpiv/minifun.mpiv45
-rw-r--r--metapost/context/base/mpiv/mp-blob.mpiv133
-rw-r--r--metapost/context/base/mpiv/mp-grph.mpiv69
-rw-r--r--metapost/context/base/mpiv/mp-luas.mpiv17
-rw-r--r--metapost/context/base/mpiv/mp-mlib.mpiv303
5 files changed, 407 insertions, 160 deletions
diff --git a/metapost/context/base/mpiv/minifun.mpiv b/metapost/context/base/mpiv/minifun.mpiv
new file mode 100644
index 000000000..6d877fddb
--- /dev/null
+++ b/metapost/context/base/mpiv/minifun.mpiv
@@ -0,0 +1,45 @@
+%D \module
+%D [ file=minifun.mp,
+%D version=2018.06.02,
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=format generation file,
+%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.
+
+%D This is a minimal \METAFUN\ instance which can be handy for isolated
+%D subruns.
+
+prologues := 0 ;
+mpprocset := 1 ;
+
+input "mp-base.mpiv" ;
+input "mp-tool.mpiv" ;
+input "mp-mlib.mpiv" ;
+input "mp-luas.mpiv" ;
+input "mp-page.mpiv" ;
+
+string minifunversion ; minifunversion =
+ "minifun iv" & " " &
+ decimal year & "-" &
+ decimal month & "-" &
+ decimal day & " " &
+ if ((time div 60) < 10) : "0" & fi
+ decimal (time div 60) & ":" &
+ if ((time-(time div 60)*60) < 10) : "0" & fi
+ decimal (time-(time div 60)*60) ;
+
+let normalend = end ;
+
+if known mplib :
+ def end = ; message "" ; message minifunversion ; message "" ; endinput ; enddef ;
+ def bye = ; message "" ; message minifunversion ; message "" ; endinput ; enddef ;
+else :
+ def end = ; message "" ; message minifunversion ; message "" ; normalend ; enddef ;
+fi ;
+
+% dump ; % obsolete in mplib
diff --git a/metapost/context/base/mpiv/mp-blob.mpiv b/metapost/context/base/mpiv/mp-blob.mpiv
index 78fa6bfe9..d2bdf741a 100644
--- a/metapost/context/base/mpiv/mp-blob.mpiv
+++ b/metapost/context/base/mpiv/mp-blob.mpiv
@@ -28,17 +28,34 @@ enddef ;
extra_endfig := extra_endfig & "mfun_reset_tex_blobs ; " ;
-vardef mfun_inject_blob(expr n) =
- mfun_blob_c := nullpicture ;
- mfun_blob_b := lua.mp.blob_dimensions(mfun_blob_n,n) ;
- addto mfun_blob_c doublepath unitsquare
- xscaled redpart mfun_blob_b
- yscaled (greenpart mfun_blob_b + bluepart mfun_blob_b)
- shifted (0,- bluepart mfun_blob_b)
- withprescript "tb_stage=inject"
- withprescript "tb_blob=" & decimal lua.mp.blob_index(mfun_blob_n,n) ;
- mfun_blob_c
-enddef ;
+if mfun_use_one_pass :
+
+ vardef mfun_inject_blob(expr n) =
+ mfun_blob_c := nullpicture ;
+ mfun_blob_b := lua.mp.blob_dimensions(mfun_blob_n,n) ;
+ addto mfun_blob_c doublepath unitsquare
+ xscaled redpart mfun_blob_b
+ yscaled (greenpart mfun_blob_b + bluepart mfun_blob_b)
+ shifted (0,- bluepart mfun_blob_b)
+ withprescript "tb_blob=" & decimal lua.mp.blob_index(mfun_blob_n,n) ;
+ mfun_blob_c
+ enddef ;
+
+else :
+
+ vardef mfun_inject_blob(expr n) =
+ mfun_blob_c := nullpicture ;
+ mfun_blob_b := lua.mp.blob_dimensions(mfun_blob_n,n) ;
+ addto mfun_blob_c doublepath unitsquare
+ xscaled redpart mfun_blob_b
+ yscaled (greenpart mfun_blob_b + bluepart mfun_blob_b)
+ shifted (0,- bluepart mfun_blob_b)
+ withprescript "tb_stage=inject"
+ withprescript "tb_blob=" & decimal lua.mp.blob_index(mfun_blob_n,n) ;
+ mfun_blob_c
+ enddef ;
+
+fi ;
% An example of usage:
@@ -47,15 +64,12 @@ newinternal tracingfollowtext ; tracingfollowtext := 0 ;
newinternal autoscaleupfollowtext ; autoscaleupfollowtext := 2 ;
newinternal autoscaledownfollowtext ; autoscaledownfollowtext := 0 ;
-vardef followtext(expr pth, txt) =
- image (
- mfun_blob_n := mfun_blob_n + 1 ;
- if mfun_trial_run :
- draw fullcircle scaled 100bp
- withprescript "ft_stage=trial"
- withprescript "ft_category=" & decimal mfun_blob_n
- withpostscript txt ;
- else :
+if mfun_use_one_pass :
+
+ vardef followtext(expr pth, txt) =
+ image (
+ mfun_blob_n := mfun_blob_n + 1 ;
+ lua.mp.InjectBlobB(mfun_blob_n,txt);
save pat, al, at, pl, pc, wid, pos, ap, ad, pic, len, n, sc ;
path pat ; pat := pth ;
numeric al, at, pl, pc, wid, pos, len[], n, sc ;
@@ -113,6 +127,79 @@ vardef followtext(expr pth, txt) =
draw fullcircle scaled 100bp
withprescript "ft_stage=final"
withprescript "ft_category=" & decimal mfun_blob_n ;
- fi ;
- )
-enddef ;
+ )
+ enddef ;
+
+else :
+
+ vardef followtext(expr pth, txt) =
+ image (
+ mfun_blob_n := mfun_blob_n + 1 ;
+ if mfun_trial_run :
+ draw fullcircle scaled 100bp
+ withprescript "ft_stage=trial"
+ withprescript "ft_category=" & decimal mfun_blob_n
+ withpostscript txt ;
+ else :
+ save pat, al, at, pl, pc, wid, pos, ap, ad, pic, len, n, sc ;
+ path pat ; pat := pth ;
+ numeric al, at, pl, pc, wid, pos, len[], n, sc ;
+ pair ap, ad ;
+ picture pic[] ;
+ len[0] := 0 ;
+ n := lua.mp.blob_size(mfun_blob_n) ;
+ sc := 0 ;
+ for i=1 upto n :
+ pic[i] := mfun_inject_blob(i) ;
+ pic[i] := pic[i] shifted - llcorner pic[i] ;
+ len[i] := len[i-1] + lua.mp.blob_width(mfun_blob_n,i) ;
+ endfor ;
+ al := arclength pth ;
+ if al = 0 :
+ al := len[n] ;
+ pat := origin -- (al,0) ;
+ fi ;
+ if ((al < len[n]) and (autoscaleupfollowtext > 0)) or
+ ((al > len[n]) and (autoscaledownfollowtext > 0)) :
+ sc := len[n] /al ;
+ pat := pat scaled sc ;
+ al := arclength pat ;
+ fi ;
+ if followtextalternative = 1 :
+ pl := (al-len[n])/(if n>1 : (n-1) else : 1 fi) ;
+ pc := 0 ;
+ else : % centered / MP
+ pl := 0 ;
+ pc := arclength pat/2 - len[n]/2 ;
+ fi ;
+ if tracingfollowtext = 1 :
+ draw pat withpen pencircle scaled 1pt withcolor blue ;
+ fi ;
+ for i=1 upto n :
+ wid := lua.mp.blob_width(mfun_blob_n,i) ;
+ pos := len[i]-wid/2 + (i-1)*pl + pc ;
+ at := arctime pos of pat ;
+ ap := point at of pat ;
+ ad := direction at of pat ;
+ pic[i] := pic[i] shifted (-wid/2,0) rotated(angle(ad)) shifted ap ;
+ draw pic[i] ;
+ if tracingfollowtext = 1 :
+ draw boundingbox pic[i] withpen pencircle scaled .25pt withcolor red ;
+ draw ap withpen pencircle scaled .50pt withcolor green ;
+ fi ;
+ endfor ;
+ if ((autoscaleupfollowtext = 2) or (autoscaledownfollowtext = 2)) and
+ (sc <> 0) and (sc <> 1):
+ currentpicture := currentpicture scaled (1/sc) ;
+ fi ;
+ if tracingfollowtext = 1 :
+ draw boundingbox currentpicture withpen pencircle scaled .25pt withcolor blue ;
+ fi ;
+ draw fullcircle scaled 100bp
+ withprescript "ft_stage=final"
+ withprescript "ft_category=" & decimal mfun_blob_n ;
+ fi ;
+ )
+ enddef ;
+
+fi ;
diff --git a/metapost/context/base/mpiv/mp-grph.mpiv b/metapost/context/base/mpiv/mp-grph.mpiv
index 04d4920f6..2fc000b9d 100644
--- a/metapost/context/base/mpiv/mp-grph.mpiv
+++ b/metapost/context/base/mpiv/mp-grph.mpiv
@@ -128,33 +128,52 @@ picture mfun_gt_picture ;
% this is the old version:
-def old_graphictext primary t =
- hide (
- if mfun_trial_run :
- let mfun_graphic_text = mfun_no_graphic_text ;
- else :
- let mfun_graphic_text = mfun_do_graphic_text ;
- fi
- )
- mfun_graphic_text(t)
-enddef ;
+if mfun_use_one_pass :
-def mfun_do_graphic_text (expr t) =
- % withprescript "gt_stage=final"
- begingroup ;
- save figurepicture ; picture figurepicture ;
- figurepicture := currentpicture ; currentpicture := nullpicture ;
- currentgraphictext := currentgraphictext + 1 ;
- mfun_finish_graphic_text % picks up directives
-enddef ;
+ def old_graphictext primary t =
+ mfun_do_graphic_text(t)
+ enddef ;
-def mfun_no_graphic_text (expr t) text rest =
- currentgraphictext := currentgraphictext + 1 ;
- draw unitsquare
- withprescript "gt_stage=trial"
- withprescript "gt_index=" & decimal currentgraphictext
- withpostscript t
-enddef ;
+ def mfun_do_graphic_text (expr t) =
+ begingroup ;
+ save figurepicture ; picture figurepicture ;
+ figurepicture := currentpicture ; currentpicture := nullpicture ;
+ currentgraphictext := currentgraphictext + 1 ;
+ lua.mp.GraphicText(currentgraphictext,t) ;
+ mfun_finish_graphic_text % picks up directives
+ enddef ;
+
+else :
+
+ def old_graphictext primary t =
+ hide (
+ if mfun_trial_run :
+ let mfun_graphic_text = mfun_no_graphic_text ;
+ else :
+ let mfun_graphic_text = mfun_do_graphic_text ;
+ fi
+ )
+ mfun_graphic_text(t)
+ enddef ;
+
+ def mfun_do_graphic_text (expr t) =
+ % withprescript "gt_stage=final"
+ begingroup ;
+ save figurepicture ; picture figurepicture ;
+ figurepicture := currentpicture ; currentpicture := nullpicture ;
+ currentgraphictext := currentgraphictext + 1 ;
+ mfun_finish_graphic_text % picks up directives
+ enddef ;
+
+ def mfun_no_graphic_text (expr t) text rest =
+ currentgraphictext := currentgraphictext + 1 ;
+ draw unitsquare
+ withprescript "gt_stage=trial"
+ withprescript "gt_index=" & decimal currentgraphictext
+ withpostscript t
+ enddef ;
+
+fi ;
def mfun_finish_graphic_text text rest =
protectgraphicmacros ; % resets currentpicture
diff --git a/metapost/context/base/mpiv/mp-luas.mpiv b/metapost/context/base/mpiv/mp-luas.mpiv
index d35701ec6..3bc95349d 100644
--- a/metapost/context/base/mpiv/mp-luas.mpiv
+++ b/metapost/context/base/mpiv/mp-luas.mpiv
@@ -49,17 +49,24 @@ boolean context_luas ; context_luas := true ;
%
% Fourth variant:
-string mfun_lua_bs ; mfun_lua_bs := "[[" ;
-string mfun_lua_es ; mfun_lua_es := "]]" ;
+string mfun_lua_bs ; mfun_lua_bs := "[===[" ;
+string mfun_lua_es ; mfun_lua_es := "]===]" ;
vardef mlib_luas_luacall(text t) =
runscript("" for s = t :
if string s :
& s
+% & mfun_lua_bs & s & mfun_lua_es
elseif numeric s :
& decimal s
elseif boolean s :
& if s : "true" else : "false" fi
+ elseif pair s :
+ & mfun_pair_to_table(s)
+ elseif rgbcolor s :
+ & mfun_rgb_to_table(s)
+ elseif cmykcolor s :
+ & mfun_cmyk_to_table(s)
else :
& ditto & tostring(s) & ditto
fi endfor
@@ -81,6 +88,12 @@ vardef mlib_luas_lualist(expr c)(text t) =
& decimal s
elseif boolean s :
& if s : "true" else : "false" fi
+ elseif pair s :
+ & mfun_pair_to_table(s)
+ elseif rgbcolor s :
+ & mfun_rgb_to_table(s)
+ elseif cmykcolor s :
+ & mfun_cmyk_to_table(s)
else :
& ditto & tostring(s) & ditto
fi endfor & ")"
diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv
index 28a9ebfc5..4308111d0 100644
--- a/metapost/context/base/mpiv/mp-mlib.mpiv
+++ b/metapost/context/base/mpiv/mp-mlib.mpiv
@@ -16,6 +16,10 @@ if known context_mlib : endinput ; fi ;
boolean context_mlib ; context_mlib := true ;
+numeric LUATEXFUNCTIONALITY ; LUATEXFUNCTIONALITY := runscript("mp.print(LUATEXFUNCTIONALITY)") ;
+
+boolean mfun_use_one_pass ; mfun_use_one_pass := runscript("mp.print(metapost.use_one_pass)") ;
+
%D Color and transparency
%D
%D Separable:
@@ -174,71 +178,70 @@ 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.
-% see mp-keep.mpiv for older code
+boolean mfun_onetime_textext ; mfun_onetime_textext := false ;
-% 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 ;
+if mfun_use_one_pass :
-boolean mfun_onetime_textext ; mfun_onetime_textext := false ;
+ % todo: onetime
-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 ;
- if mfun_trial_run :
+ rgbcolor mfun_tt_r ;
+
+ vardef rawtextext(expr s) =
+ if s = "" :
+ 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.SomeText(mfun_tt_n,s) ;
addto mfun_tt_c doublepath unitsquare
- withprescript "tx_number=" & decimal mfun_tt_n
- withprescript "tx_stage=trial"
+ xscaled redpart mfun_tt_r
+ yscaled (greenpart mfun_tt_r + bluepart mfun_tt_r)
+ shifted (0,-bluepart mfun_tt_r)
+ withprescript "tx_index=" & decimal mfun_tt_n
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 ;
+ ;
+ mfun_tt_c
+ fi
+ enddef ;
+
+else :
+
+ vardef rawtextext(expr s) = % todo: avoid currentpicture
+ if s = "" :
+ mfun_onetime_textext := false ;
+ nullpicture
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 ;
+ 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 ;
+ 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 ;
+
+fi ;
vardef validtexbox(expr category, name) =
if category == "" :
@@ -431,49 +434,74 @@ enddef ;
% formatted text
-pair mfun_tt_z ;
+if mfun_use_one_pass :
-vardef rawfmttext(text t) = % todo: avoid currentpicture
- mfun_tt_n := mfun_tt_n + 1 ;
- mfun_tt_c := nullpicture ;
- if mfun_trial_run :
+ vardef rawfmttext(text t) =
+ 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.SomeFormattedText(mfun_tt_n,t) ;
addto mfun_tt_c doublepath unitsquare
- withprescript "tx_number=" & decimal mfun_tt_n
- withprescript "tx_stage=trial"
+ xscaled redpart mfun_tt_r
+ yscaled (greenpart mfun_tt_r + bluepart mfun_tt_r)
+ shifted (0,-bluepart mfun_tt_r)
+ 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 ;
+ mfun_tt_c
+ enddef ;
+
+else :
+
+ pair mfun_tt_z ;
+
+ vardef rawfmttext(text t) = % todo: avoid currentpicture
+ 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
+ % 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
- 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
+ if pair s : 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 ;
+ mfun_onetime_textext := false ;
+ mfun_tt_c
+ enddef ;
+
+fi ;
vardef thefmttext@#(text t) =
mfun_tt_z := origin ;
@@ -1146,21 +1174,17 @@ def mfun_do_outline_options_d = enddef ;
def mfun_do_outline_options_f = enddef ;
def mfun_do_outline_options_r = enddef ;
-vardef outlinetext@# (expr t) text rest =
- save kind ; string kind ; kind := str @# ;
- currentoutlinetext := currentoutlinetext + 1 ;
- def mfun_do_outline_options_d = enddef ;
- def mfun_do_outline_options_f = enddef ;
- def mfun_do_outline_options_r = enddef ;
- image ( normaldraw image (
- if mfun_trial_run :
+if mfun_use_one_pass :
+
+ vardef outlinetext@# (expr t) text rest =
+ save kind ; string kind ; kind := str @# ;
+ currentoutlinetext := currentoutlinetext + 1 ;
+ def mfun_do_outline_options_d = enddef ;
+ def mfun_do_outline_options_f = enddef ;
+ def mfun_do_outline_options_r = enddef ;
+ image ( normaldraw image (
% 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 :
+ lua.mp.OutlineText(currentoutlinetext,t,kind) ;
% lua.mp.report("get outline text",currentoutlinetext);
if kind = "f" :
mfun_do_outline_text_set_f rest ;
@@ -1178,9 +1202,48 @@ vardef outlinetext@# (expr t) text rest =
mfun_do_outline_text_set_n rest ;
fi ;
lua.mp.get_outline_text(currentoutlinetext) ;
- fi ;
- ) mfun_do_outline_options_r ; )
-enddef ;
+ ) mfun_do_outline_options_r ; )
+ enddef ;
+
+else :
+
+ vardef outlinetext@# (expr t) text rest =
+ save kind ; string kind ; kind := str @# ;
+ currentoutlinetext := currentoutlinetext + 1 ;
+ def mfun_do_outline_options_d = enddef ;
+ def mfun_do_outline_options_f = enddef ;
+ def mfun_do_outline_options_r = enddef ;
+ image ( normaldraw image (
+ 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 :
+ % 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 ;
+ ) mfun_do_outline_options_r ; )
+ enddef ;
+
+fi ;
% A few helpers:
@@ -1209,7 +1272,6 @@ 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 ; " ;
@@ -1254,9 +1316,9 @@ def withproperties expr p =
withcolor (cyanpart p,magentapart p,yellowpart p,blackpart p)
fi
withpen penpart p
- % if dashpart p <> nullpicture : % fails
+ if length (dashpart p) > 0 :
dashed dashpart p
- % fi
+ fi
withprescript prescriptpart p
withpostscript postscriptpart p
enddef ;
@@ -1357,6 +1419,27 @@ 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_rgbcolor_to_table(expr c) =
+ "{" & decimal redpart c &
+ "," & decimal greenpart c &
+ "," & decimal bluepart c &
+ "}"
+enddef ;
+
+vardef mfun_cmykcolor_to_table(expr c) =
+ "{" & decimal cyanpart c &
+ "," & decimal magentapart c &
+ "," & decimal yellowpart c &
+ "," & decimal blackpart c &
+ "}"
+enddef ;
+
vardef mfun_greycolor_to_string(expr n) =
decimal n
enddef ;