diff options
author | Hans Hagen <pragma@wxs.nl> | 2019-09-29 16:35:50 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2019-09-29 16:35:50 +0200 |
commit | fd8697791360a26a2b9cc888dbc125cefedfcd42 (patch) | |
tree | f1257c9ce132fd942b69a559e9961e6dbe6f1539 /metapost | |
parent | 0a5f59a9aa25b3de7e9659b39ad201aaf7eb5a67 (diff) | |
download | context-fd8697791360a26a2b9cc888dbc125cefedfcd42.tar.gz |
2019-09-29 14:42:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpiv/mp-lmtx.mpxl | 96 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-mlib.mpiv | 5 |
2 files changed, 93 insertions, 8 deletions
diff --git a/metapost/context/base/mpiv/mp-lmtx.mpxl b/metapost/context/base/mpiv/mp-lmtx.mpxl index 359c60921..46f399dc9 100644 --- a/metapost/context/base/mpiv/mp-lmtx.mpxl +++ b/metapost/context/base/mpiv/mp-lmtx.mpxl @@ -1496,10 +1496,9 @@ presetparameters "contour" [ def lmt_contour = applyparameters "contour" "lmt_do_contour" enddef ; -boolean lmx_contour_loaded ; lmx_contour_loaded := false ; - def mfun_only_draw = addto currentpicture doublepath enddef ; def mfun_only_fill = addto currentpicture contour enddef ; +def mfun_only_fillup text t = addto currentpicture doublepath t withpostscript "both" enddef ; def mfun_only_nodraw text t = addto currentpicture doublepath t withpostscript "collect" enddef ; def mfun_only_nofill text t = addto currentpicture contour t withpostscript "evenodd" enddef ; def mfun_only_eofill text t = addto currentpicture contour t withpostscript "collect" enddef ; @@ -1508,10 +1507,13 @@ def lmt_do_contour_shortcuts = save D ; let D = mfun_only_draw ; save E ; let E = mfun_only_eofill ; save F ; let F = mfun_only_fill ; + save U ; let U = mfun_only_fillup ; save d ; let d = mfun_only_nodraw ; save e ; let f = mfun_only_eofill ; save f ; let f = mfun_only_nofill ; save C ; let C = cycle ; + save B ; let B = controls ; + save A ; let A = and ; enddef ; def lmt_do_contour_band = @@ -1638,15 +1640,17 @@ def lmt_do_contour_shades(expr outlines) = fi ; enddef ; +def lmt_load_mlib_cnt = + runscript("lua.registercode('mlib-cnt')"); + extra_beginfig := extra_beginfig & % todo: use different hook + "runscript(" & ditto & "mp.lmt_contours_cleanup()" & ditto & ")" ; + let lmt_load_mlib_cnt = relax ; +enddef ; + vardef lmt_do_contour = image ( - if not lmx_contour_loaded : - lmx_contour_loaded := true ; - runscript("lua.registercode('mlib-cnt')"); - extra_beginfig := extra_beginfig & % todo: use different hook - "runscript(" & ditto & "mp.lmt_contours_cleanup()" & ditto & ")" ; - fi + lmt_load_mlib_cnt ; pushparameters "contour" ; @@ -2028,3 +2032,79 @@ vardef lmt_do_svg = fi enddef ; +% Another experiment. Parameters might change pending a discussion between Alan +% and me. + +presetparameters "surface" [ + code = "x + y", + color = "f, 0, 0", + linecolor = 1, + xmin = -1, + xmax = 1, + ymin = -1, + ymax = 1, + xstep = .1, + ystep = .1, + snap = .01, + xvector = { -0.7, -0.7 }, + yvector = { 1, 0 }, + zvector = { 0, 1 }, + light = { 3, 3, 10 }, + bright = 100, + clip = false, + lines = true, + linecolor = 1, + % axis = { } + % clipaxis = false + axiscolor = "gray" + axislinewidth = 1/2, +] ; + +def lmt_surface = applyparameters "surface" "lmt_do_surface" enddef ; + +vardef lmt_do_surface = + image ( + + lmt_load_mlib_cnt ; + + pushparameters "surface" ; + + save currentpen; pen currentpen ; + currentpen := pencircle scaled .25 ; + + interim linejoin := butt ; + + lmt_do_contour_shortcuts ; + + lua.mp.lmt_surface_do() ; + + currentpicture := currentpicture ysized getparameter "height" ; + + if hasparameter "axis" : + + save p ; picture p ; p := image ( + if hasparameter "axis" 1 : + draw ((origin) -- unitvector(getparameter "xvector")) scaled (getparameter "axis" 1) ; + fi ; + if hasparameter "axis" 2 : + draw ((origin) -- unitvector(getparameter "yvector")) scaled (getparameter "axis" 2) ; + fi ; + if hasparameter "axis" 3 : + draw ((origin) -- unitvector(getparameter "zvector")) scaled (getparameter "axis" 3) ; + fi ; + ) ; + + if getparameterdefault "clipaxis" false : + clip p to boundingbox currentpicture ; + fi ; + + draw p + withpen pencircle scaled getparameter "axislinewidth" + withcolor getparameter "axiscolor" + ; + + fi ; + + popparameters ; + ) +enddef ; diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index 286e4e495..88bf56674 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -1696,6 +1696,11 @@ def nodraw text t = draw t withpostscript "collect" enddef ; def dodraw text t = draw t withpostscript "flush" enddef ; def dofill text t = fill t withpostscript "flush" enddef ; +% maybe (saves a bogus path but the problem is that it can influence the dimensions): + +% def dodraw text t = draw center currentpicture withpostscript "flush" enddef ; +% def dofill text t = fill center currentpicture --cycle withpostscript "flush" enddef ; + if contextlmtxmode : def eoclip text t = clip t withpostscript "evenodd" enddef ; else : |