3

I want to create a node style which looks like this:

enter image description here

After some investigations I was not able to succeed and identified two directions to achieve this goal. I am asking here which direction should I take and how continue into this direction.

The first direction seems to use append after command in my style definition as following:

channel/.style={ 
        fifo,minimum size=4mm,minimum width=10mm,
        append after command={
          (\tikzlastnode.north west)edge(\tikzlastnode.north east)
          (\tikzlastnode.south west)edge(\tikzlastnode.south east)
          (\tikzlastnode.north east)edge(\tikzlastnode.south east)
        }
}

My problem with this solution is that I don't know how to extend it to draw de "other" vertical lines in my node.

The second direction consist in declaring a new shape as clearly described here How to draw inside a TikZ node, using node style? My problem with this solution is it's relative complexity and how to draw these lines using \pgf primitives.

Feel free to add any other solution that may better suits this need.

Manuel Selva
  • 1,839

1 Answers1

6

One solution would be to just add more edges at the appropriate spots. This version adds four vertical lines evenly distributed along the length:

enter image description here

Notes:

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\tikzset{channel/.style={ minimum size=4mm, minimum width=10mm, append after command={ (\tikzlastnode.north west)edge(\tikzlastnode.north east) (\tikzlastnode.south west)edge(\tikzlastnode.south east) ([shift={(0,+0.5\pgflinewidth)}]\tikzlastnode.north east)edge ([shift={(0,-0.5\pgflinewidth)}]\tikzlastnode.south east) ([shift={(0,+0.5\pgflinewidth)}] $(\tikzlastnode.north west)!0.8!(\tikzlastnode.north east)$)edge ([shift={(0,-0.5\pgflinewidth)}] $(\tikzlastnode.south west)!0.8!(\tikzlastnode.south east)$) ([shift={(0,+0.5\pgflinewidth)}] $(\tikzlastnode.north west)!0.6!(\tikzlastnode.north east)$)edge ([shift={(0,-0.5\pgflinewidth)}] $(\tikzlastnode.south west)!0.6!(\tikzlastnode.south east)$) ([shift={(0,+0.5\pgflinewidth)}] $(\tikzlastnode.north west)!0.4!(\tikzlastnode.north east)$)edge ([shift={(0,-0.5\pgflinewidth)}] $(\tikzlastnode.south west)!0.4!(\tikzlastnode.south east)$) ([shift={(0,+0.5\pgflinewidth)}] $(\tikzlastnode.north west)!0.2!(\tikzlastnode.north east)$)edge ([shift={(0,-0.5\pgflinewidth)}] $(\tikzlastnode.south west)!0.2!(\tikzlastnode.south east)$) } } }

\begin{document} \begin{tikzpicture} \node [channel] (Channel1) at (0, 0) {}; \node [channel, minimum width=20mm] (Channel1) at (0, -0.5) {}; \end{tikzpicture} \end{document}

Peter Grill
  • 223,288