diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-01 11:38:58 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-01 11:38:58 +0200 |
commit | 665f9095475ffcd1c8750546727c75e5486a266f (patch) | |
tree | 347186e688c8435eed7fcdff0052e6ae1272964d /metapost | |
parent | 5135aef167bec739fe429e1aa987671768b237bc (diff) | |
download | context-665f9095475ffcd1c8750546727c75e5486a266f.tar.gz |
2016-08-01 10:54:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpiv/mp-mlib.mpiv | 7 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-tool.mpiv | 54 |
2 files changed, 60 insertions, 1 deletions
diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index 4c9f6442a..a4541ae2d 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -909,6 +909,10 @@ vardef mfun_do_outline_text_flush (expr kind, n, x, y) (text t) = fi ; enddef ; +vardef mfun_do_outline_rule_flush (expr kind, x, y, w, h) = + mfun_do_outline_text_flush (kind, 1, x, y) (fullsquare xyscaled(w,h)) +enddef ; + numeric mfun_do_outline_n ; mfun_do_outline_n := 0 ; vardef mfun_do_outline_text_f (expr n, x, y) (text t) = @@ -1009,6 +1013,9 @@ 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 : % lua.mp.report("set outline text",currentoutlinetext); diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index 9e086f0df..ae2ce3435 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -996,6 +996,56 @@ primarydef p randomshifted s = endgroup enddef ; +vardef mfun_randomized_path(expr p,s) = + for i=0 upto length(p)-1 : + (point i of p) .. controls + ((postcontrol i of p) randomshifted s) and + ((precontrol (i+1) of p) randomshifted s) .. + endfor + if cycle p : + cycle + else : + (point length(p) of p) + fi +enddef; + +vardef mfun_randomized_picture(expr p,s)(text rnd) = + save currentpicture ; + picture currentpicture ; + currentpicture := nullpicture ; + for i within p : + addto currentpicture + if stroked i : + doublepath pathpart i rnd s + dashed dashpart i + withpen penpart i + withcolor colorpart i + withprescript prescriptpart i + withpostscript postscriptpart i + elseif filled i : + contour pathpart i rnd s + withpen penpart i + withcolor colorpart i + withprescript prescriptpart i + withpostscript postscriptpart i + else : + also i + fi + ; + endfor ; + currentpicture +enddef ; + +primarydef p randomizedcontrols s = ( + if path p : + mfun_randomized_path(p,s) + elseif picture p : + mfun_randomized_picture(p,s)(randomizedcontrols) + else : + p randomized s + fi +) enddef ; + primarydef p randomized s = ( if path p : for i=0 upto length(p)-1 : @@ -1041,6 +1091,8 @@ primarydef p randomized s = ( fi elseif string p : (resolvedcolor(p)) randomized s + elseif picture p : + mfun_randomized_picture(p,s)(randomized) else : p + uniformdeviate s fi @@ -1943,7 +1995,7 @@ def reprocess suffix p = p := repathed (22,p) enddef ; % no attributes vardef repathed (expr mode, p) text t = begingroup ; if mode = 0 : - save withcolor ; + save normalwithcolor ; remapcolors ; fi ; save _p_, _pp_, _ppp_, _f_, _b_, _t_ ; |