# Underlining Text in tikz

I have drawn a picture using tikz the code of which is shown below:

\begin{tikzpicture}
\draw [rounded corners=10pt] (0,0) rectangle (4,2);
\draw (-3,1) -- (0,1) node [near start, above]{incoming communication};
\draw (2,3) -- (2,2) node [near start,left]{ input};
\draw (2,-1.5) -- (2,0) node [midway, left] {subroutine output};
\draw (1, 1.3) -- (3.5, 1.3) node [midway, above] {identity};
\draw (1, 0.5) -- (3.5, 0.5) node [midway, above] {sec. param.};
\end{tikzpicture}


the output is like this:

Is it possible that the text inside the rectangle be underlined and the line to be as long as the text (like a simple underlined text)?

Is it possible to have each line leading to the rectangle to be like a negative (photo film). I can imagine that some rectangles of thick borders which are set aside each other can do the job of the negative. is there any possibility of scaling a picture of negative and using the pattern for a line? or I must draw those rectangles and have them glued together? :D

-
For the underlining: why not simply use \ul from the ulem package? –  Caramdir Dec 19 '10 at 12:53
You mean I draw an invisible path and make the text underlined in normal way? I don't know how to make invisible path. It is possible to draw the path as white but the text would be white too (I don't know how to change the color of the text itself and not the whole path). –  Yasser Sobhdel Dec 19 '10 at 13:06
You should use \node to place text at arbitrary positions (see the TikZ manual). (btw, the command is \uline, not \ul). –  Caramdir Dec 19 '10 at 13:28

To create underlined text, simply use the ulem package:

\documentclass{article}
\usepackage{ulem,tikz}

\begin{document}
\tikz
{
\node at (0,0.5) {\uline{some underlined text}};
\node at (0,0) {\uline{a second line}};
}
\end{document}


To create the filmstrip effect, you could use decorations. See chapter 72 of the TikZ manual (v2.10) for how to define your own decoration (the use of decorations is described in chapter 21). The following could get you started (it won't look good with curved paths or paths with edges):

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations}
\begin{document}
\pgfdeclaredecoration{film}{initial}
{
\state{initial}[width=10pt]
{
\fill (0,-5pt) rectangle (10.2pt,5pt);
\fill[white,rounded corners=1pt] (2pt,-4pt) rectangle (8pt,4pt);
}
\state{final}
{
\begin{scope}
\clip (0,-5pt) rectangle (\pgfdecoratedremainingdistance,5pt);
\fill (0,-5pt) rectangle (10pt,5pt);
\fill[white,rounded corners=1pt] (2pt,-4pt) rectangle (8pt,4pt);
\end{scope}
\pgfpathmoveto{\pgfpointdecoratedpathlast}
}
}

\tikz[decoration=film]
{
\draw [decorate] (0,0) -- (3,0);
}
\end{document}


-