diff options
author | Hans Hagen <pragma@wxs.nl> | 2013-08-28 23:08:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2013-08-28 23:08:00 +0200 |
commit | 944d2c4b1bfa004f6d6eb0aefb0c80bda272c0df (patch) | |
tree | 2793a0e023f93abd1f73a3ed902c8a3c8f68e0f1 /metapost | |
parent | 6636e93b03360741f50b4f809b086b6cbf342abd (diff) | |
download | context-944d2c4b1bfa004f6d6eb0aefb0c80bda272c0df.tar.gz |
beta 2013.08.28 23:08
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mp-grap.mpiv | 18 | ||||
-rw-r--r-- | metapost/context/base/mp-mlib.mpiv | 121 |
2 files changed, 104 insertions, 35 deletions
diff --git a/metapost/context/base/mp-grap.mpiv b/metapost/context/base/mp-grap.mpiv index 00a4d12cb..a7115fc7a 100644 --- a/metapost/context/base/mp-grap.mpiv +++ b/metapost/context/base/mp-grap.mpiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See licen-en.pdf for %C details. +% laboff -> mfun_laboff or use plain_label instead + if known context_grap : endinput ; fi ; boolean context_grap ; context_grap := true ; @@ -354,7 +356,7 @@ vardef graph_set_bounds@#(expr l, h) = graph_clear_bounds@# ; if @#graph_coordinate_type>0 : @#low = if unknown l : - whatever + whatever else : if abs @#graph_coordinate_type=log : graph_mlog fi if string l : scantokens fi l fi ; @@ -364,7 +366,7 @@ vardef graph_set_bounds@#(expr l, h) = if abs @#graph_coordinate_type=log : graph_mlog fi if string h : scantokens fi h fi ; else : - -@#high = if unknown l : + -@#high = if unknown l : whatever else : if abs @#graph_coordinate_type=log : graph_mlog fi if string l : scantokens fi l @@ -644,7 +646,7 @@ enddef ; % Stash the result drawing command c in the graph_label table using with list w and % an index based on angle laboff$. vardef graph_stash_label(suffix $)(text c) text w = - graph_label[1.5+angle laboff$ /90] = image(c(origin) w) ; + graph_label[1.5+angle mfun_laboff$ /90] = image(c(origin) w) ; enddef ; @@ -701,7 +703,7 @@ enddef ; % Generate label positioning arguments appropriate for label suffix $ and % coordinate u. def graph_generate_label_position(suffix $)(expr u) = - if xpart laboff.$=0 : u,whatever else : whatever,u fi + if xpart mfun_laboff.$=0 : u,whatever else : whatever,u fi enddef ; @@ -715,9 +717,9 @@ vardef graph_gridline_picture@#(suffix $)(expr c, f, u)(text w) = save p ; path p; interim warningcheck :=0 ; graph_autogrid_needed :=false ; - p = Gtemplate$ zscaled -laboff@# + p = Gtemplate$ zscaled -mfun_laboff@# if c : Gxyscale fi - shifted (((.5 + laboff@# dotprod (.5,.5)) * laboff@#) Gxyscale) ; + shifted (((.5 + mfun_laboff@# dotprod (.5,.5)) * mfun_laboff@#) Gxyscale) ; image(draw p w ; label@#(if string f : format(f,u) else : f fi, point 0 of p)) fi @@ -730,7 +732,7 @@ vardef frame@# text w = graph_frame_needed :=false ; picture p_ ; p_ = image(draw - if str@#<>"" : subpath round(angle laboff@#*graph_frame_pair_a+graph_frame_pair_b) of fi + if str@#<>"" : subpath round(angle mfun_laboff@#*graph_frame_pair_a+graph_frame_pair_b) of fi unitsquare Gxyscale w) ; graph_draw_label((whatever,whatever),,draw p_ shifted) ; enddef ; @@ -906,7 +908,7 @@ def auto suffix $ = if graph_select_exponent_mark.graph_exponent : graph_generate_exponents(graph_exponent, graph_comma graph_factor_and_exponent_to_string(1,e)) - else : + else : graph_scan_mark(graph_select_mark, graph_modified_lower, graph_modified_higher, graph_comma graph_factor_and_exponent_to_string(m,e)) fi diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv index abf0eb974..214faec5b 100644 --- a/metapost/context/base/mp-mlib.mpiv +++ b/metapost/context/base/mp-mlib.mpiv @@ -99,6 +99,8 @@ 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 ; @@ -117,6 +119,8 @@ 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 = @@ -131,37 +135,100 @@ 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) = +% 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 if str = "" : nullpicture - elseif mfun_trial_run : + else : mfun_tt_n := mfun_tt_n + 1 ; - addto mfun_tt_p doublepath unitsquare - withprescript "tx_number=" & decimal mfun_tt_n - withprescript "tx_stage=extra" - withpostscript str ; - image ( - addto currentpicture doublepath unitsquare + 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" - 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]) + 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" ; else : - image ( - addto currentpicture doublepath unitsquare ; - ) - fi + addto mfun_tt_c doublepath unitsquare ; % unitpicture + fi ; + mfun_tt_c fi enddef ; @@ -651,8 +718,8 @@ else : elseif colormodel p = 7 : withcolor (cyanpart p,magentapart p,yellowpart p,blackpart p) fi - withprescript prescript p - withpostscript postscript p + withprescript prescriptpart p + withpostscript postscriptpart p enddef ; fi ; |