summaryrefslogtreecommitdiff
path: root/metapost/context/base/mp-mlib.mpiv
diff options
context:
space:
mode:
Diffstat (limited to 'metapost/context/base/mp-mlib.mpiv')
-rw-r--r--metapost/context/base/mp-mlib.mpiv233
1 files changed, 27 insertions, 206 deletions
diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv
index e667e4064..9a2042924 100644
--- a/metapost/context/base/mp-mlib.mpiv
+++ b/metapost/context/base/mp-mlib.mpiv
@@ -99,8 +99,6 @@ newinternal textextoffset ; textextoffset := 0 ;
numeric mfun_tt_w[], mfun_tt_h[], mfun_tt_d[] ; % we can consider using colors (less hash space)
numeric mfun_tt_n ; mfun_tt_n := 0 ;
picture mfun_tt_p ; mfun_tt_p := nullpicture ;
-picture mfun_tt_o ; mfun_tt_o := nullpicture ;
-picture mfun_tt_c ; mfun_tt_c := nullpicture ;
if unknown mfun_trial_run :
boolean mfun_trial_run ;
@@ -119,8 +117,6 @@ fi ;
def mfun_reset_tex_texts =
mfun_tt_n := 0 ;
mfun_tt_p := nullpicture ;
- mfun_tt_o := nullpicture ; % redundant
- mfun_tt_c := nullpicture ; % redundant
enddef ;
def mfun_flush_tex_texts =
@@ -135,100 +131,37 @@ 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.
-% vardef rawtextext(expr str) =
-% if str = "" :
-% nullpicture
-% elseif mfun_trial_run :
-% mfun_tt_n := mfun_tt_n + 1 ;
-% mfun_tt_o := image(draw origin) ; % save drawoptions
-% addto mfun_tt_p doublepath unitsquare
-% withprescript "tx_number=" & decimal mfun_tt_n
-% withprescript "tx_stage=extra"
-% withpostscript str ;
-% image (
-% addto currentpicture doublepath unitsquare
-% withprescript "tx_number=" & decimal mfun_tt_n
-% withprescript "tx_stage=trial"
-% withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
-% withpostscript str
-% ; )
-% else :
-% mfun_tt_n := mfun_tt_n + 1 ;
-% if known mfun_tt_d[mfun_tt_n] :
-% image (
-% addto currentpicture doublepath unitsquare
-% xscaled mfun_tt_w[mfun_tt_n]
-% yscaled (mfun_tt_h[mfun_tt_n] + mfun_tt_d[mfun_tt_n])
-% withprescript "tx_number=" & decimal mfun_tt_n
-% withprescript "tx_stage=final"
-% % withpostscript str ; % for tracing
-% ; ) shifted (0,-mfun_tt_d[mfun_tt_n])
-% else :
-% image (
-% addto currentpicture doublepath unitsquare
-% ; )
-% fi
-% fi
-% enddef ;
-
-% vardef rawtextext(expr str) = % todo: avoid currentpicture
-% if str = "" :
-% 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_p doublepath unitsquare
-% withprescript "tx_number=" & decimal mfun_tt_n
-% withprescript "tx_stage=extra"
-% withpostscript str ;
-% 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 str ;
-% 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 ;
-
-vardef rawtextext(expr str) = % todo: avoid currentpicture
+vardef rawtextext(expr str) =
if str = "" :
nullpicture
- else :
+ elseif mfun_trial_run :
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
+ addto mfun_tt_p doublepath unitsquare
+ withprescript "tx_number=" & decimal mfun_tt_n
+ withprescript "tx_stage=extra"
+ withpostscript str ;
+ image (
+ addto currentpicture doublepath unitsquare
withprescript "tx_number=" & decimal mfun_tt_n
withprescript "tx_stage=trial"
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- withpostscript str ;
- 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" ;
+ withpostscript str
+ )
+ else :
+ mfun_tt_n := mfun_tt_n + 1 ;
+ if known mfun_tt_d[mfun_tt_n] :
+ image (
+ addto currentpicture doublepath unitsquare
+ xscaled mfun_tt_w[mfun_tt_n]
+ yscaled (mfun_tt_h[mfun_tt_n] + mfun_tt_d[mfun_tt_n])
+ withprescript "tx_number=" & decimal mfun_tt_n
+ withprescript "tx_stage=final"
+ ; % withpostscript str ;
+ ) shifted (0,-mfun_tt_d[mfun_tt_n])
else :
- addto mfun_tt_c doublepath unitsquare ; % unitpicture
- fi ;
- mfun_tt_c
+ image (
+ addto currentpicture doublepath unitsquare ;
+ )
+ fi
fi
enddef ;
@@ -322,46 +255,6 @@ mfun_labtype.drt := 12 ;
mfun_labtype.origin := 0 ;
mfun_labtype.raw := 0 ;
-% installlabel.foo ( 0, 1, 1, (.5,-1) ) ;
-
-vardef installlabel@# (expr type, x, y, offset) =
- numeric labtype@# ; labtype@# := type ;
- pair laboff @# ; laboff @# := offset ;
- numeric labxf @# ; labxf @# := x ;
- numeric labyf @# ; labyf @# := y ;
-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@# - (labxf@#*lrcorner p + labyf@#*ulcorner p + (1-labxf@#-labyf@#)*llcorner p))
- fi
-enddef;
-
-def plain_label = % takes two arguments, contrary to textext that takes one
- draw plain_thelabel
-enddef ;
-
-let mfun_label = label ;
-let mfun_thelabel = thelabel ;
-
-def useplainlabels = % somehow let doesn't work for all code
- def label = plain_label enddef ;
- def thelabel = plain_thelabel enddef ;
-enddef ;
-
-def usemetafunlabels =
- let label = mfun_label ;
- let thelabel = mfun_thelabel ;
-enddef ;
-
-plain_compatibility_data := plain_compatibility_data & "save label, thelabel ;" & "useplainlabels ;" ;
-
-% next comes own own:
-
vardef thetextext@#(expr p,z) =
% interim labeloffset := textextoffset ;
if string p :
@@ -718,8 +611,8 @@ else :
elseif colormodel p = 7 :
withcolor (cyanpart p,magentapart p,yellowpart p,blackpart p)
fi
- withprescript prescriptpart p
- withpostscript postscriptpart p
+ withprescript prescript p
+ withpostscript postscript p
enddef ;
fi ;
@@ -769,75 +662,3 @@ enddef ;
% draw textext.autoalign(160)("\strut oeps 2") ;
% draw textext.autoalign(260)("\strut oeps 3") ;
% draw textext.autoalign(360)("\strut oeps 4") ;
-
-% new
-%
-% passvariable("version","1.0") ;
-% passvariable("number",123) ;
-% passvariable("string","whatever") ;
-% passvariable("point",(1,2)) ;
-% passvariable("triplet",(1,2,3)) ;
-% passvariable("quad",(1,2,3,4)) ;
-% passvariable("boolean",false) ;
-% passvariable("path",fullcircle scaled 1cm) ;
-
-vardef mfun_point_to_string(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_transform_to_string(expr t) =
- decimal xxpart t & " " & % rx
- decimal xypart t & " " & % sx
- decimal yxpart t & " " & % sy
- decimal yypart t & " " & % ry
- decimal xpart t & " " & % tx
- decimal ypart t % ty
-enddef ;
-
-vardef mfun_numeric_to_string(expr n) =
- decimal n
-enddef ;
-
-vardef mfun_pair_to_string(expr p) =
- decimal xpart p & " " &
- decimal ypart p
-enddef ;
-
-vardef mfun_rbgcolor_to_string(expr c) =
- decimal redpart c & " " &
- decimal greenpart c & " " &
- decimal bluepart c
-enddef ;
-
-vardef mfun_cmykcolor_to_string(expr c) =
- decimal cyanpart c & " " &
- decimal magentapart c & " " &
- decimal yellowpart c & " " &
- decimal blackpart c
-enddef ;
-
-vardef mfun_path_to_string(expr p) =
- mfun_point_to_string(p,0) for i=1 upto length(p) : & " " & mfun_point_to_string(p,i) endfor
-enddef ;
-
-vardef mfun_boolean_to_string(expr b) =
- if b : "true" else : "false" fi
-enddef ;
-
-def passvariable(expr key, value) =
- special
- if numeric value : "1:" & key & "=" & mfun_numeric_to_string(value)
- elseif pair value : "4:" & key & "=" & mfun_pair_to_string(value)
- elseif rgbcolor value : "5:" & key & "=" & mfun_rgbcolor_to_string(value)
- elseif cmykcolor value : "6:" & key & "=" & mfun_cmykcolor_to_string(value)
- elseif boolean value : "3:" & key & "=" & mfun_boolean_to_string(value)
- elseif path value : "7:" & key & "=" & mfun_path_to_string(value)
- elseif transform value : "8:" & key & "=" & mfun_transform_to_string(value)
- else : "2:" & key & "=" & value
- fi ;
-enddef ;