Drawing lines within circle using TikZ
Using clipping? I am using a scope
here to restrict the clipping to it.
\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\draw [clip] (0,0) circle (1cm);
\draw (0,-1) -- (0,1); % first (center) line
\foreach \x in {1,...,4} {% 4 lines per side
\draw (\x/10, -1) -- (\x/10,1); % positive x position 0.1, 0.2...
\draw (-\x/10, -1) -- (-\x/10,1); % and negative ones
}
\end{scope}
\end{tikzpicture}
\end{document}
(Notice that the seemingly bigger line at the center is an aliasing problem of the PDF viewer).
Using scopes let you manipulate the thing quite easily:
\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\draw [clip] (0,0) circle (1cm);
\draw (0,-1) -- (0,1); % first diagonal
\foreach \x in {1,...,4} {% 4 lines
\draw (\x/10, -1) -- (\x/10,1);
\draw (-\x/10, -1) -- (-\x/10,1);
}
\end{scope}
\begin{scope}[xshift=2cm, scale=0.5, rotate=45]
\draw [clip] (0,0) circle (1cm);
\draw (0,-1) -- (0,1); % first diagonal
\foreach \x in {1,...,4} {% 4 lines
\draw (\x/10, -1) -- (\x/10,1);
\draw (-\x/10, -1) -- (-\x/10,1);
}
\end{scope}
\end{tikzpicture}
\end{document}
For fun, here is a style vlines
using path picture
and grid
to draw the lines.
\documentclass[tikz,border=7pt]{standalone}
\tikzset{
vlines/.style={
path picture={
\draw[xstep=#1, ystep=100cm, shift={(path picture bounding box.south west)} ]
(path picture bounding box.south west) grid (path picture bounding box.north east);
}
}
}
\begin{document}
\begin{tikzpicture}
\draw[vlines=2mm] (0,0) circle (1);
\end{tikzpicture}
\end{document}
Note : The ystep=100cm
can be set to the height of path picture bounding box
but this is another story ;)