I'm trying to get TikZ to make a sort of experience bar command where I can just call it and enter a number out of say, 6, and it will return that many "filled" dots, and 6 minus that many "unfilled" dots. Problem is, something with the way the "foreach" command counts sizes makes it mess up, either by adding too many dots or not enough or not in the right spot or something (depending on what specifically I do with the index bounds)
For example:
\newcommand{\dotexp}[1]{
\tikz{\foreach \x in {1,...,#1}
\draw[cyan,fill=cyan] (\x/2.5,0) circle (.5ex);
\ifnum#1<6 \foreach \y in {#1,...,6} \draw[lightgray,fill=lightgray] (\y/2.5,0) circle (.5 ex);\fi}
}
gives me
where each line is supposed to be a call for 0, 1, 2,....6 dots, in order.
Any suggestions for a fix? Maybe some way to pre-allocate the dot positioning but just change the color?





\dotexp{0}because you've specified that the second loop starts at#1, and 0,1,...,6 makes for seven dots. – Torbjørn T. Jan 03 '18 at 08:07