I want to create a \rating
command that draws a partly filled circle, according to a numeric parameter between 0 and 100:
Question: How can I modify the expression for determining the angles in arc
, so that the filling rises more steadily over the whole value range? Right now, ratings from 0 to 20 look empty, 80 to 100 look completely filled and only in between there is a steady rise.
Clarification: Rather than a mathematically rigoros expression, I am looking for the simplest expression that looks right, i.e. that \rating{25}
, \rating{50}
and \rating{75}
visually look like 1/4, 2/4 and 3/4.
\documentclass{minimal}
\usepackage{tikz}
\newcommand{\rating}[1]{
\begin{tikzpicture}
\fill[lightgray] ({270-1.8*#1}:1ex) arc ({270-1.8*#1}:{270+1.8*#1}:1ex) -- cycle;
\draw[black, thin, radius=1ex] (0,0) circle;
\end{tikzpicture}}
\begin{document}
This really should scale\dots
\rating{0} \rating{10} \rating{20} \rating{30} \rating{40} \rating{50}
\rating{50} \rating{60} \rating{70} \rating{80} \rating{90} \rating{100}
\dots linearly.
\end{document}
Best Answer
As an aside, please see Why should the minimal class be avoided?
Here is a solution using a
clip
ped path in TikZ. Note that the clip path cannot have extra options added, so I've drawn the circle with your specifications separately, outside the scope of the\clip
path.