summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-05-12 01:19:03 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-05-12 01:19:03 +0200
commit77e216e323271fb85d508b7206b13c980540b74b (patch)
tree5b4053c2bbe5190e28c0dce89653c7b13aea0642 /metapost
parentd817aef76ab8b606c02bd0636661b634b43a68a6 (diff)
downloadcontext-77e216e323271fb85d508b7206b13c980540b74b.tar.gz
2018-05-12 00:16:00
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mpiv/mp-mlib.mpiv17
-rw-r--r--metapost/context/base/mpiv/mp-tool.mpiv29
2 files changed, 43 insertions, 3 deletions
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 ;