[Tex/LaTex] In-line graphics in text to represent a loading bar for language skills in a CV

cvgraphicsloopsmoderncv

I would like to add my language skills to my CV in the following manner:

Language skills as loading bars

I could of course create an image in Inkscape for every language, and put it in in a most straightforward way, maybe as described in:
Micro-graphics inline in text

But from that thread it looks like it could be automated, so that one maybe could write \loadingbar{4.5,5} and get 4.5 filled circles out of five. Maybe also with some optional parameters for size or colors.

I know it reads a little bit like "solve this problem for me", but especially the part with colors I have no idea how to even approach, and also how to do loops in Latex properly. So if anyone wants to take it on as a challenge I would be more than happy 🙂

Best Answer

Works only for integer of semi integer values.

\documentclass{report}
\usepackage{tikz}
\newcommand{\grade}[1]{%
\begin{tikzpicture}
\clip (1em-.3em,-.3em) rectangle (5em +.5em ,.3em);
\begin{scope}
\clip (1em-.3em,-.3em) rectangle (#1em +.5em ,.3em);
\foreach \x in {1,2,...,5}{
 \path[fill=red] (\x em,0) circle (.25em);
}
\end{scope}
\foreach \x in {1,2,...,5}{
 \draw (\x em,0) circle (.25em);
}
\end{tikzpicture}%
}
\begin{document}

\begin{tabular}{ll}
Danish: & \grade{5}  \\
English:& \grade{4.5}\\
German: & \grade{3.5}  \\
French: & \grade{0}
\end{tabular}

\end{document}

enter image description here