I want to draw polygons that have a fixed width shading or border on the inside. Here is an image made in mspaint illustrating the kind of thing I'd like to draw:
This question addresses this issue, and an answer is given using code suggested by Mark Wibrow. But Wibrow's code includes a fill command that specifies white as the fill colour. What if I want a choice of fill colour? I could make that a second parameter of the key, but this is conceptually the wrong way to organise things. Fill colour and internal border are separate concerns, and the internal border drawing key shouldn't have to be told about the fill colour. In other words, we should be able to just choose whether to combine our new key with the "fill" key, and it should just work that way.
This might be produced by code (essentially Wibrow's) that looks like this, except that it doesn't quite work:
\documentclass{standalone}
\usepackage{tikz}
\newlength{\internalborderwidth}
\setlength{\internalborderwidth}{1mm}
\tikzset{internal border/.style = {
preaction = {clip, postaction = {draw = #1, line width = \internalborderwidth}}
}}
\definecolor{lightpeach} {rgb}{0.9765, 0.9608, 0.8588}
\definecolor{mylightgreen}{rgb}{0.7098, 0.9020, 0.1137}
\definecolor{mylightblue} {rgb}{0.6000, 0.8510, 0.9176}
\definecolor{mypink} {rgb}{1.0000, 0.6824, 0.7882}
\begin{document}
\begin{tikzpicture}
\draw [fill = lightpeach, internal border = mylightgreen]
(0, 0) -- (2, 5) -- (6, 3) -- cycle;
\draw [fill = lightpeach, internal border = mylightblue]
(0, 0) -- (6, 3) -- (7, 1) -- cycle;
\draw [fill = lightpeach, internal border = mypink]
(0, 0) -- (7, 1) -- (3.5, -1.5) -- cycle;
\end{tikzpicture}
\end{document}
The reason why it doesn't work is that the "fill" action occurs after the preaction. So the coloured border gets filled over. But Wibrow's action can't be used as a postaction either; then it would happen after the ordinary border (the thin black line) was drawn, so it would wipe that out. Maybe you could add "draw" in there to get it drawn again, but you'd lose any styles applied alongside the internal border key, like if I had specified a colour for it.
Really what I need is to be able to specify an action to occur in between filling and drawing (when fill and draw are combined, it is filling that occurs first, per page 171 of the TikZ/PGF version 3 manual). Of course, I could specify the path twice, first to fill it and then to draw it, but I do not want to have to repeat myself like that.


