diff options
author | Hans Hagen <pragma@wxs.nl> | 2021-03-05 12:17:06 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2021-03-05 12:17:06 +0100 |
commit | cd05787a9d41bac345695564011d333974afe1d9 (patch) | |
tree | ecc998d3de192ddcccdf1fcb1ec56fc3d539c2f9 /metapost | |
parent | 0d300509bdd7497fd376844b2326f5917636590e (diff) | |
download | context-cd05787a9d41bac345695564011d333974afe1d9.tar.gz |
2021-03-05 11:16:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpiv/mp-back.mpiv | 336 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-tool.mpiv | 2 | ||||
-rw-r--r-- | metapost/context/base/mpxl/mp-text.mpxl | 35 | ||||
-rw-r--r-- | metapost/context/base/mpxl/mp-tool.mpxl | 4 |
4 files changed, 192 insertions, 185 deletions
diff --git a/metapost/context/base/mpiv/mp-back.mpiv b/metapost/context/base/mpiv/mp-back.mpiv index f588adea9..e77b3f0d9 100644 --- a/metapost/context/base/mpiv/mp-back.mpiv +++ b/metapost/context/base/mpiv/mp-back.mpiv @@ -22,14 +22,15 @@ def some_hash ( expr hash_width , hash_angle , hash_gap ) = - stripe_gap := hash_gap ; - stripe_angle := hash_angle ; - drawoptions (withpen pencircle scaled hash_linewidth - withcolor hash_linecolor) ; - path p ; p := unitsquare xscaled hash_width yscaled hash_height ; - stripe_path_a () (draw) p ; % next we move it all to quadrant 1 - currentpicture := currentpicture shifted urcorner currentpicture ; - + begingroup ; + stripe_gap := hash_gap ; + stripe_angle := hash_angle ; + drawoptions (withpen pencircle scaled hash_linewidth + withcolor hash_linecolor) ; + path p ; p := unitsquare xscaled hash_width yscaled hash_height ; + stripe_path_a () (draw) p ; % next we move it all to quadrant 1 + currentpicture := currentpicture shifted urcorner currentpicture ; + endgroup ; enddef ; def some_double_back (expr back_type , @@ -44,162 +45,167 @@ def some_double_back (expr back_type , back_leftcolor , back_rightcolor ) = - numeric ww ; ww := back_width ; - numeric hh ; hh := back_height ; - numeric dd ; dd := back_delta ; - - color back_nillcolor ; back_nillcolor := back_topcolor ; - - path p ; p := fullsquare xscaled ww yscaled hh ; - path q ; q := fullsquare xscaled (ww-2dd) yscaled (hh-2dd) ; - path r ; r := llcorner p -- - lrcorner p shifted (-3dd,0) .. controls lrcorner p .. - lrcorner p shifted (0, 3dd) -- - urcorner p shifted (0,-3dd) .. controls urcorner p .. - urcorner p shifted (-3dd,0) -- - ulcorner p -- cycle ; - path s ; s := r xscaled ((ww-2dd)/ww) yscaled ((hh-2dd)/hh) ; - path t ; t := llcorner p -- - lrcorner p -- - urcorner p shifted (0,-3dd) .. controls urcorner p .. - urcorner p shifted (-3dd,0) -- - ulcorner p shifted ( 3dd,0) .. controls ulcorner p .. - ulcorner p shifted (0,-3dd) -- - llcorner p -- cycle ; - path u ; u := t xscaled ((ww-2dd)/ww) yscaled ((hh-2dd)/hh) ; - path v ; v := llcorner p shifted ( 3dd,0) -- - lrcorner p shifted (-3dd,0) .. controls lrcorner p .. - lrcorner p shifted (0, 3dd) -- - urcorner p shifted (0,-3dd) .. controls urcorner p .. - urcorner p shifted (-3dd,0) -- - ulcorner p shifted ( 3dd,0) .. controls ulcorner p .. - ulcorner p shifted (0,-3dd) .. - llcorner p shifted (0, 3dd) .. controls llcorner p .. cycle ; % {down} .. cycle ; - path w ; w := t xscaled ((ww-2dd)/ww) yscaled ((hh-2dd)/hh) ; - path a ; a := llcorner p -- ulcorner p -- - ulcorner q -- llcorner q -- cycle ; - path b ; b := llcorner p -- lrcorner p -- - lrcorner q -- llcorner q -- cycle ; - path c ; c := lrcorner p -- urcorner p -- - urcorner q -- lrcorner q -- cycle ; - path d ; d := ulcorner p -- urcorner p -- - urcorner q -- ulcorner q -- cycle ; - path e ; e := llcorner p -- lrcorner p -- - urcorner p -- urcorner q -- - lrcorner q -- llcorner q -- cycle ; - path f ; f := llcorner p -- ulcorner p -- - urcorner p -- urcorner q -- - ulcorner q -- llcorner q -- cycle ; - - linecap := butt ; pickup pencircle scaled back_linewidth ; - - if back_type=1 : - - fill p withcolor back_fillcolor ; - fill a withcolor back_leftcolor ; - fill b withcolor back_bottomcolor ; - fill c withcolor back_rightcolor ; - fill d withcolor back_topcolor ; - draw a withcolor back_linecolor ; - draw d withcolor back_linecolor ; - draw b withcolor back_linecolor ; - draw c withcolor back_linecolor ; - - elseif back_type=2 : - - fill p withcolor back_fillcolor ; - fill e withcolor back_bottomcolor ; - fill f withcolor back_topcolor ; - draw e withcolor back_linecolor ; - draw f withcolor back_linecolor ; - - elseif back_type=3 : - - fill v withcolor back_nillcolor ; - fill w withcolor back_fillcolor ; - draw v withcolor back_linecolor ; - draw w withcolor back_linecolor ; - - elseif back_type=4 : - - fill t withcolor back_nillcolor ; - fill u withcolor back_fillcolor ; - draw t withcolor back_linecolor ; - draw u withcolor back_linecolor ; - - elseif back_type=5 : - - t := t rotatedaround(center t,180) ; - u := u rotatedaround(center u,180) ; - - fill t withcolor back_nillcolor ; - fill u withcolor back_fillcolor ; - draw t withcolor back_linecolor ; - draw u withcolor back_linecolor ; - - elseif back_type=6 : - - r := r rotatedaround(center r,180) ; - s := s rotatedaround(center s,180) ; - - fill r withcolor back_nillcolor ; - fill s withcolor back_fillcolor ; - draw r withcolor back_linecolor ; - draw s withcolor back_linecolor ; - - elseif back_type=7 : - - fill r withcolor back_nillcolor ; - fill s withcolor back_fillcolor ; - draw r withcolor back_linecolor ; - draw s withcolor back_linecolor ; - -fi ; - + begingroup ; + + save ww, hh, dd, p, q, r, s, t, u, v, w, a, c, d, e, f, back_nillcolor ; + + numeric ww ; ww := back_width ; + numeric hh ; hh := back_height ; + numeric dd ; dd := back_delta ; + + color back_nillcolor ; back_nillcolor := back_topcolor ; + + path p ; p := fullsquare xscaled ww yscaled hh ; + path q ; q := fullsquare xscaled (ww-2dd) yscaled (hh-2dd) ; + path r ; r := llcorner p -- + lrcorner p shifted (-3dd,0) .. controls lrcorner p .. + lrcorner p shifted (0, 3dd) -- + urcorner p shifted (0,-3dd) .. controls urcorner p .. + urcorner p shifted (-3dd,0) -- + ulcorner p -- cycle ; + path s ; s := r xscaled ((ww-2dd)/ww) yscaled ((hh-2dd)/hh) ; + path t ; t := llcorner p -- + lrcorner p -- + urcorner p shifted (0,-3dd) .. controls urcorner p .. + urcorner p shifted (-3dd,0) -- + ulcorner p shifted ( 3dd,0) .. controls ulcorner p .. + ulcorner p shifted (0,-3dd) -- + llcorner p -- cycle ; + path u ; u := t xscaled ((ww-2dd)/ww) yscaled ((hh-2dd)/hh) ; + path v ; v := llcorner p shifted ( 3dd,0) -- + lrcorner p shifted (-3dd,0) .. controls lrcorner p .. + lrcorner p shifted (0, 3dd) -- + urcorner p shifted (0,-3dd) .. controls urcorner p .. + urcorner p shifted (-3dd,0) -- + ulcorner p shifted ( 3dd,0) .. controls ulcorner p .. + ulcorner p shifted (0,-3dd) .. + llcorner p shifted (0, 3dd) .. controls llcorner p .. cycle ; % {down} .. cycle ; + path w ; w := t xscaled ((ww-2dd)/ww) yscaled ((hh-2dd)/hh) ; + path a ; a := llcorner p -- ulcorner p -- + ulcorner q -- llcorner q -- cycle ; + path b ; b := llcorner p -- lrcorner p -- + lrcorner q -- llcorner q -- cycle ; + path c ; c := lrcorner p -- urcorner p -- + urcorner q -- lrcorner q -- cycle ; + path d ; d := ulcorner p -- urcorner p -- + urcorner q -- ulcorner q -- cycle ; + path e ; e := llcorner p -- lrcorner p -- + urcorner p -- urcorner q -- + lrcorner q -- llcorner q -- cycle ; + path f ; f := llcorner p -- ulcorner p -- + urcorner p -- urcorner q -- + ulcorner q -- llcorner q -- cycle ; + + linecap := butt ; pickup pencircle scaled back_linewidth ; + + if back_type = 1 : + + fill p withcolor back_fillcolor ; + fill a withcolor back_leftcolor ; + fill b withcolor back_bottomcolor ; + fill c withcolor back_rightcolor ; + fill d withcolor back_topcolor ; + draw a withcolor back_linecolor ; + draw d withcolor back_linecolor ; + draw b withcolor back_linecolor ; + draw c withcolor back_linecolor ; + + elseif back_type = 2 : + + fill p withcolor back_fillcolor ; + fill e withcolor back_bottomcolor ; + fill f withcolor back_topcolor ; + draw e withcolor back_linecolor ; + draw f withcolor back_linecolor ; + + elseif back_type = 3 : + + fill v withcolor back_nillcolor ; + fill w withcolor back_fillcolor ; + draw v withcolor back_linecolor ; + draw w withcolor back_linecolor ; + + elseif back_type = 4 : + + fill t withcolor back_nillcolor ; + fill u withcolor back_fillcolor ; + draw t withcolor back_linecolor ; + draw u withcolor back_linecolor ; + + elseif back_type = 5 : + + t := t rotatedaround(center t,180) ; + u := u rotatedaround(center u,180) ; + + fill t withcolor back_nillcolor ; + fill u withcolor back_fillcolor ; + draw t withcolor back_linecolor ; + draw u withcolor back_linecolor ; + + elseif back_type = 6 : + + r := r rotatedaround(center r,180) ; + s := s rotatedaround(center s,180) ; + + fill r withcolor back_nillcolor ; + fill s withcolor back_fillcolor ; + draw r withcolor back_linecolor ; + draw s withcolor back_linecolor ; + + elseif back_type = 7 : + + fill r withcolor back_nillcolor ; + fill s withcolor back_fillcolor ; + draw r withcolor back_linecolor ; + draw s withcolor back_linecolor ; + + fi ; + + endgroup; enddef ; -endinput ; - -beginfig (1) ; - -some_double_back (1, 4.5cm, 1.5cm, .25cm, 1mm, - .5white, .8white, .7white, .6white, .7white, .6white) - -currentpicture := currentpicture shifted (0,-3cm) ; - -some_double_back (2, 4.5cm, 1.5cm, .25cm, 1mm, - .5white, .8white, .7white, .6white, white, white) - -currentpicture := currentpicture shifted (0,-3cm) ; - -some_double_back (3, 4.5cm, 1.5cm, .25cm, 1mm, - .5white, .8white, .7white, white, white, white) - -currentpicture := currentpicture shifted (0,-3cm) ; - -some_double_back (4, 4.5cm, 1.5cm, .25cm, 1mm, - .5white, .8white, .7white, white, white, white) - -currentpicture := currentpicture shifted (0,-3cm) ; - -some_double_back (5, 4.5cm, 1.5cm, .25cm, 1mm, - .5white, .8white, .7white, white, white, white) - -currentpicture := currentpicture shifted (0,-3cm) ; - -some_double_back (6, 4.5cm, 1.5cm, .25cm, 1mm, - .5white, .8white, .7white, white, white, white) - -currentpicture := currentpicture shifted (0,-3cm) ; - -some_double_back (7, 4.5cm, 1.5cm, .25cm, 1mm, - .5white, .8white, .7white, white, white, white) - -currentpicture := currentpicture shifted (0,-3cm) ; - -some_double_back (8, 4.5cm, 1.5cm, .25cm, 1mm, - .5white, .8white, .7white, white, white, white) - -endfig ; - -end . +% endinput ; +% +% beginfig (1) ; +% +% some_double_back (1, 4.5cm, 1.5cm, .25cm, 1mm, +% .5white, .8white, .7white, .6white, .7white, .6white) +% +% currentpicture := currentpicture shifted (0,-3cm) ; +% +% some_double_back (2, 4.5cm, 1.5cm, .25cm, 1mm, +% .5white, .8white, .7white, .6white, white, white) +% +% currentpicture := currentpicture shifted (0,-3cm) ; +% +% some_double_back (3, 4.5cm, 1.5cm, .25cm, 1mm, +% .5white, .8white, .7white, white, white, white) +% +% currentpicture := currentpicture shifted (0,-3cm) ; +% +% some_double_back (4, 4.5cm, 1.5cm, .25cm, 1mm, +% .5white, .8white, .7white, white, white, white) +% +% currentpicture := currentpicture shifted (0,-3cm) ; +% +% some_double_back (5, 4.5cm, 1.5cm, .25cm, 1mm, +% .5white, .8white, .7white, white, white, white) +% +% currentpicture := currentpicture shifted (0,-3cm) ; +% +% some_double_back (6, 4.5cm, 1.5cm, .25cm, 1mm, +% .5white, .8white, .7white, white, white, white) +% +% currentpicture := currentpicture shifted (0,-3cm) ; +% +% some_double_back (7, 4.5cm, 1.5cm, .25cm, 1mm, +% .5white, .8white, .7white, white, white, white) +% +% currentpicture := currentpicture shifted (0,-3cm) ; +% +% some_double_back (8, 4.5cm, 1.5cm, .25cm, 1mm, +% .5white, .8white, .7white, white, white, white) +% +% endfig ; +% +% end . diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index e2f59acfd..c84d8dfbf 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -3356,7 +3356,7 @@ let dump = relax ; def loadmodule expr name = % no vardef % input can't be used directly in a macro - if unknown scantokens("context_" & name) : + if (unknown scantokens("context_" & name)) and (unknown scantokens("metafun_loaded_" & name)) : save s ; string s ; % s := "mp-" & name & ".mpiv" ; % message("loading module",s) ; diff --git a/metapost/context/base/mpxl/mp-text.mpxl b/metapost/context/base/mpxl/mp-text.mpxl index 02dbf4479..c18647baf 100644 --- a/metapost/context/base/mpxl/mp-text.mpxl +++ b/metapost/context/base/mpxl/mp-text.mpxl @@ -40,13 +40,14 @@ def lmt_parshape = applyparameters "parshape" "lmt_do_parshape" enddef ; def lmt_do_parshape = % todo: check and improve this rather oldie - begingroup ; + begingroup ; pushparameters "parshape" ; save p, q, l, r, line, tt, bb, dx, dy, baselineskip, strutheight, strutdepth, topskip, bottomskip, offset, trace, n, hsize, vsize, vvsize, voffset, hoffset, width, indent, - ll, lll, rr, rrr, cp, cq, t, b ; + ll, lll, rr, rrr, cp, cq, t, b, + found_point ; path p, q, l, r, line, tt, bb ; @@ -60,24 +61,24 @@ def lmt_do_parshape = % todo: check and improve this rather oldie % specification: - p := getparameterdefault "parshape" "path" fullsquare ; - dx := getparameterdefault "parshape" "dx" 0 ; - dy := getparameterdefault "parshape" "dy" 0 ; - baselineskip := getparameterdefault "parshape" "baselineskip" LineHeight ; - strutheight := getparameterdefault "parshape" "strutheight" StrutHeight ; - strutdepth := getparameterdefault "parshape" "strutdepth" StrutDepth ; - topskip := getparameterdefault "parshape" "topskip" StrutHeight ; - bottomskip := getparameterdefault "parshape" "bottomskip" 0 ; - offset := getparameterdefault "parshape" "offset" 0 ; - trace := getparameterdefault "parshape" "trace" false ; + p := getparameterdefault "path" fullsquare ; + dx := getparameterdefault "dx" 0 ; + dy := getparameterdefault "dy" 0 ; + baselineskip := getparameterdefault "baselineskip" LineHeight ; + strutheight := getparameterdefault "strutheight" StrutHeight ; + strutdepth := getparameterdefault "strutdepth" StrutDepth ; + topskip := getparameterdefault "topskip" StrutHeight ; + bottomskip := getparameterdefault "bottomskip" 0 ; + offset := getparameterdefault "offset" 0 ; + trace := getparameterdefault "trace" false ; % n := 0 ; cp := center p ; - if hasparameter "parshape" "offsetpath" : - q := getparameter "parshape" "offsetpath" ; + if hasparameter "offsetpath" : + q := getparameter "offsetpath" ; voffset := dy ; hoffset := dx ; else : @@ -98,7 +99,7 @@ def lmt_do_parshape = % todo: check and improve this rather oldie runscript mfid_setparshapeproperty "width" hsize ; runscript mfid_setparshapeproperty "height" vsize ; - if not path offset_or_path : + if hasparameter "offsetpath" : q := q xscaled ((hsize-2hoffset)/hsize) yscaled ((vsize-2voffset)/vsize) ; fi ; @@ -119,7 +120,7 @@ def lmt_do_parshape = % todo: check and improve this rather oldie r := r if xpart point 0 of q > 0 : & q fi cutafter t ; vardef found_point (expr lin, pat, sig) = - pair a, b ; + save a, b; pair a, b ; a := pat intersection_point (lin shifted (0,strutheight)) ; if intersection_found : a := a shifted (0,-strutheight) ; @@ -183,7 +184,7 @@ def lmt_do_parshape = % todo: check and improve this rather oldie runscript mfid_setparshapeproperty "line" i (indent[i]) (width[i]) ; endfor ; - endgroup ; + popparameters ; endgroup ; enddef ; diff --git a/metapost/context/base/mpxl/mp-tool.mpxl b/metapost/context/base/mpxl/mp-tool.mpxl index d5da026f2..7ea222fb0 100644 --- a/metapost/context/base/mpxl/mp-tool.mpxl +++ b/metapost/context/base/mpxl/mp-tool.mpxl @@ -3464,8 +3464,8 @@ let dump = relax ; def loadmodule expr name = % no vardef % input can't be used directly in a macro - if (unknown scantokens("context_" & name)) and (unknown scantokens("metafun_loaded" & name)) : - save s ; string s ; s := "input " & ditto & "mp-" & name & ditto; + if (unknown scantokens("context_" & name)) and (unknown scantokens("metafun_loaded_" & name)) : + save s ; string s ; s := "input " & ditto & "mp-" & name & ditto & ";" ; expandafter scantokens expandafter s fi ; enddef ; |