From 77e216e323271fb85d508b7206b13c980540b74b Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sat, 12 May 2018 01:19:03 +0200 Subject: 2018-05-12 00:16:00 --- metapost/context/base/mpiv/mp-mlib.mpiv | 17 ++++++++++++++--- metapost/context/base/mpiv/mp-tool.mpiv | 29 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) (limited to 'metapost') diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index 115fe63ae..28a9ebfc5 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -79,7 +79,7 @@ enddef ; def spotcolor(expr name, v) = (1) withprescript "sp_type=spot" - withprescript "sp_name=" & name + withprescript "sp_name=" & name withprescript "sp_value=" & colordecimals v enddef ; @@ -92,7 +92,7 @@ enddef ; def transparent(expr a, t)(text c) = % use withtransparency instead (1) % this permits withcolor x intoshade y - withprescript "tr_alternative=" & decimal transparency_alternative_to_number(a) + withprescript "tr_alternative=" & decimal transparency_alternative_to_number(a) withprescript "tr_transparency=" & decimal t withcolor c enddef ; @@ -1596,7 +1596,18 @@ def nofill text t = fill t withpostscript "collect" enddef ; % so we can do: withcolor "red" -vardef resolvedcolor primary s = +% vardef resolvedcolor primary s = +% % lua.mp.namedcolor(s) % conflicts with macro namedcolor +% % lua.mp.NamedColor(s) % okay but, can also be +% % lua.mp("NamedColor",s) % which gives expansion mess +% if string s : +% runscript("mp.NamedColor('" & s & "')") % faster anyway +% else : +% s +% fi +% enddef ; + +def resolvedcolor primary s = % no vardef % lua.mp.namedcolor(s) % conflicts with macro namedcolor % lua.mp.NamedColor(s) % okay but, can also be % lua.mp("NamedColor",s) % which gives expansion mess diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index 75706e09b..e2cd3e363 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -3554,3 +3554,32 @@ enddef ; vardef tocycle(suffix p)(text t) = topath(p,t) t cycle enddef ; + +% reimplemented to support paths and pictures + +def drawdot expr p = + if pair p : + addto currentpicture doublepath p + withpen currentpen _op_ + elseif path p : + draw image ( + for i=0 upto length p : + addto currentpicture doublepath point i of p + withpen currentpen _op_ ; + endfor ; + ) + elseif picture p : + draw image ( + save pp ; path pp ; + for i within p : + if stroked i or filled i : + pp := pathpart i ; + for j=0 upto length pp : + addto currentpicture doublepath point j of pp + withpen currentpen _op_ ; + endfor ; + fi ; + endfor ; + ) + fi +enddef ; -- cgit v1.2.3