# Filling shape with horizontal lines

I want to draw a triangle with another shape inside, something like this:

\begin{tikzpicture}
\path[draw, ultra thick] (0,0) -- (5,5) -- (10,0)--cycle;
\path[draw, ultra thick] (3.5,0) -- (3.5,3.5) -- (8,2) -- (8,0);
\end{tikzpicture}


now I want to fill the shape inside the triangle with horizontal lines and a label in the middle. so the first question is how can I do the lines? and the second is how can I make the label cut the lines, I mean something like this: -----A----- just not dashed...

and a bonus question :) is there a better way to draw this triangle assuming I know the length of all 3 sides? (the length of the bottom one is the sqrt72...)

Thanks!

A basic approach to fill the triangle with horizontal lines without using libraries is to use \foreach to draw the lines inside the triangle using the triangle as clipping path. For the label, just use a normal node filled white.

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\path[draw, ultra thick] (0,0) --node[above,pos=.35,sloped]{4 cm}node[above,pos=.85,sloped]{2 cm} (5,5) -- (10,0)--cycle;
\path[draw, ultra thick] (3.5,0) -- (3.5,3.5) -- (8,2) -- (8,0);
\path[clip] (0,0) -- (5,5) -- (10,0)--cycle;
\foreach \y in{0,.2,...,5}
\draw (0,\y) -- (10,\y);
\node at (5,2)[fill=white]{A};
\end{tikzpicture}

\end{document}


You can also use the patterns library as suggested by @percusse like this:

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}

\begin{tikzpicture}
\path[draw, ultra thick,pattern=horizontal lines] (0,0) --node[above,pos=.35,sloped]{4 cm}node[above,pos=.85,sloped]{2 cm} (5,5) -- (10,0)--cycle;
\path[draw, ultra thick] (3.5,0) -- (3.5,3.5) -- (8,2) -- (8,0);
\node at (5,2)[fill=white]{A};
\end{tikzpicture}

\end{document}


with a slightly different output (which you can still tweak):

Edit:

I think I initially misunderstood the question, it seems the shape inside the triangle is to be filled instead. Any way, here is the modified code:

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}

\begin{tikzpicture}
\path[draw, ultra thick] (0,0) --node[above,pos=.35,sloped]{4 cm}node[above,pos=.85,sloped]{2 cm} (5,5) -- (10,0)--cycle;
\path[draw, ultra thick,pattern=horizontal lines] (3.5,0) -- (3.5,3.5) -- (8,2) -- (8,0);
\node at (5.75,1.5) [fill=white]{A};
\end{tikzpicture}

\end{document}


• Why not just using patterns instead of clipping and drawing lines? – percusse Nov 19 '17 at 19:38
• Yes, that is possible of course as I said, I just tend to over-use basics. I'll add that, thank you. – AboAmmar Nov 19 '17 at 19:40