A brute-force attempt.
The versions where only one or two opposite sides are drawn wouldn’t have a correct area to fill. One will need to use the special \behindbackgroundpath
for this. The same is true for the other versions with two adjacent sides: they create a triangular area.
But you then need to use an extra key: /pgf/open rectangle fill
. You can disable the filling with open rectangle fill=
, i.e. an empty input. If you want to use TikZ options here (like shading, fading or such, this will get a little bit more complicated but would be doable, too.
As requested, I put the code for this shape in its own library. The files
The TikZ library only contains an \usepgflibrary
to the PGF library which contains the actual code.
For the option open rectangle sides=full
the usual background path of a rectangle
is used. The same is true, if the value of open rectangle sides
is empty. (If you want no border drawn, don’t use draw
.) This also shows how to create aliases:
\let\pgf@sh@openrectangle@<new name>\pgf@sh@openrectangle@<old name>
say, for example
\let\pgf@sh@openrectangle@tab\pgf@sh@openrectangle@enw
The naming scheme is pretty easy: all sides starting from the e
astern (counter-clockwise) side are specified:
e
draws the eastern side.
ew
draws the eastern and western side.
ews
draws the the western, the southern and the eastern side (a cup).
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{chains} \usetikzlibrary{qrr.shapes.openrectangle}
\tikzset{nodes={rounded corners, text height=\heightof{f}, text width=\widthof{aaaa}, ultra thick, draw, open rectangle fill=blue!40, shape=open rectangle,
append after command={(\tikzlastnode.south west) edge[to path={rectangle (\tikztotarget)}, very thin] (\tikzlastnode.north east)}}}
\begin{document}
\begin{tikzpicture}[x=1.1cm, Start chain/.style={start chain=ch#1 going below}, Start chain/.list={1,...,4}, node distance=+2pt]\ttfamily
\foreach \ch/\si in {1/{e, n, w, s},
2/{nws, ews, ens, enw},
3/{en, nw, ws, es},
4/{, full, ew, ns}}
\foreach \Si in \si
\node[at=(right:\ch), on chain=ch\ch, open rectangle sides=\Si] {\Si};
\end{tikzpicture}
\end{document}
Output

\pgfpathlineto
and\pgfpathmoveto
commands (where to start, where to end, etc). Do you have an idea on how to do that? There are2^4
possibilities (including no border at all and a full border). (I started something like this but I cannot find it anymore.)