summaryrefslogtreecommitdiff
path: root/metapost/context/base
diff options
context:
space:
mode:
Diffstat (limited to 'metapost/context/base')
-rw-r--r--metapost/context/base/mpiv/mp-chem.mpiv13
-rw-r--r--metapost/context/base/mpiv/mp-tool.mpiv29
2 files changed, 40 insertions, 2 deletions
diff --git a/metapost/context/base/mpiv/mp-chem.mpiv b/metapost/context/base/mpiv/mp-chem.mpiv
index 4ed9eaa8f..c5f79a88c 100644
--- a/metapost/context/base/mpiv/mp-chem.mpiv
+++ b/metapost/context/base/mpiv/mp-chem.mpiv
@@ -513,10 +513,21 @@ def chem_transformed (suffix $) = % not vardef!
fi
enddef ;
+% vardef chem_draw (expr what, r, c) (text extra) =
+% draw what
+% withpen pencircle scaled r
+% withcolor c
+% extra ;
+% enddef ;
+
vardef chem_draw (expr what, r, c) (text extra) =
draw what
withpen pencircle scaled r
- withcolor c
+ if string c :
+ if c <> "" : withcolor c fi
+ else :
+ withcolor c
+ fi
extra ;
enddef ;
diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv
index cabdf9ab2..f1f31e5f0 100644
--- a/metapost/context/base/mpiv/mp-tool.mpiv
+++ b/metapost/context/base/mpiv/mp-tool.mpiv
@@ -895,9 +895,36 @@ enddef ;
let normalwithcolor = withcolor ;
def withcolor expr c =
- normalwithcolor if string c : resolvedcolor(c) else : c fi
+ normalwithcolor if string c : resolvedcolor(c) else : c fi
enddef ;
+% I don't want a "withcolor black" in case of an empty string ... who knows
+% how that can interfere with outer colors. Somehow the next one doesn't
+% always work out ok, but why ... must be some parsing issue. Anyway, when
+% we cannot do that, we need to fix some chem macros instead as empty strings
+% now lead to black while everywhere else in context empty means: leave color
+% untouched.
+
+% def withcolor expr c =
+% if not string c :
+% normalwithcolor c
+% elseif c <> "" :
+% normalwithcolor resolvedcolor(c)
+% fi
+% enddef ;
+
+% So why does this work better than the above:
+%
+% def withcolor expr c =
+% if string c :
+% if c <> "" :
+% normalwithcolor resolvedcolor(c)
+% fi
+% else :
+% normalwithcolor c
+% fi
+% enddef ;
+
vardef colortype expr c =
if cmykcolor c : cmykcolor
elseif rgbcolor c : rgbcolor