For an archery target I need to draw (and fill) a circle which is e.g. exactly 10cm in diameter including its line. However, when using TikZs circle
path command the given radius is the middle of the line, therefore the printed circle is too large.
The solution should depend on the current line width.
Here is my code so far. The drawn lines clearly leave the given radius, but should be drawn completly inside it.
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=1cm, y=1cm, line width=2mm]
\path [draw=black,fill=yellow] (0,0) circle (5cm);
\path [draw=black,fill=red] (0,0) circle (4cm);
\path [draw=black,fill=green,line width=3mm] (0,0) circle (3cm);
\draw [thin,gray] (-6,-6) grid (6,6);
\end{tikzpicture}
\end{document}
Best Answer
in
tikz
any coordinate of any path command is determined for the infinitely thin lines. the real lines lie over them so that their centers matches.line width of real lines is accessible with length
\pgflinewidth
. knowing it, it is simple to correct size of some elementary shapes as are rectangles, squares and circles with considering line widths. for example:\draw[very thick] (x1+0.5\pgflinewidth,y1+0.5\pgflinewidth) rectangle (x2-0.5\pgflinewidth,y2+0.5\pgflinewidth);
wherex1
,y1
andx2
,y2
are coordinates of rectangle. an example of comparison of two rectangles: the red rectangle has width4cm + \pgflinewidth = 4.1cm
, and the width of the yellow (that we can see it borders, it is drawn semitransparent) is exactly4cm
.\draw[very thick] (0,0) circle (<radius>-0.5\pgflinewidth);
where<radius>
circle radius size. an example of comparison of two circles is done similarly as above for rectangles: the red circle has diameter2cm + \pgflinewidth = 4.1cm
, diameter of the the yellow circle is exactly4cm
.considering above, the circles from question with outer line border exactly as given with circles' radius are as follows: