Initial Question
I may be asking the wrong question, or phrasing it incorrectly, but here is my goal: I would like to have the color of a tikz rectangle alternate between 2 different colors. The ultimate goal is to use 6 colors, but I tried to remove all the complications from my example. Every time I draw the frame, I want the color to change. To get that result, I have the following MWE:
\documentclass{article}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{xcolor}
\newcounter{Color}
\setcounter{Color}{1}
\definecolor{c1}{RGB}{58, 116, 182}
\definecolor{c2}{RGB}{83, 166, 219}
\tikzset{
check Color count/.code={
\ifthenelse{\value{\theColor}=1}{\tikzset{draw = c1}}{\tikzset{draw = c2}}
}
}
\newcommand{\textframe}{%
\begin{tikzpicture}%
\node[check Color count, rectangle, line width = 5pt] (r) {TEXT};%
\end{tikzpicture}%
}
\begin{document}
\textframe
\setcounter{Color}{2}
\textframe
\end{document}
This does not work, and I'm pretty sure it has to do with expansion, but I do not know how to fix the code. Note that I did refer to Macro inside TikZ node properties as a possible solution (which is how I ended up with this MWE).
Final solution
The chosen answer led me to a final solution that is much simpler than my initial attempt (my original attempt involved nested macros). This allows me to use text frames throughout my document without worrying about specifying the color, as the color is automatically incremented with every use.
\documentclass{article}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{xcolor}
\newcounter{Color}
\setcounter{Color}{1}
\definecolor{c1}{RGB}{58, 116, 182}
\definecolor{c2}{RGB}{83, 166, 219}
\definecolor{c3}{RGB}{152, 95, 85}
\definecolor{c4}{RGB}{220, 80, 65}
\definecolor{c5}{RGB}{175, 49, 52}
\definecolor{c6}{RGB}{232, 152, 63}
\newcommand{\nextColor}{%
\stepcounter{Color}%
\ifthenelse{\theColor>6}%
{\setcounter{Color}{1}}%
{}%
}
\tikzset{%
get Color/.code={%
\tikzset{draw = c\theColor}%
}%
}
\newcommand{\textframe}[1]{%
\begin{tikzpicture}%
\node[get Color, rectangle, line width = 5pt] (r) {#1};%
\end{tikzpicture}%
\nextColor%
}
\begin{document}
\textframe{TEXT COLOR c\theColor}\par
\textframe{TEXT COLOR c\theColor}\par
\textframe{TEXT COLOR c\theColor}\par
\textframe{TEXT COLOR c\theColor}\par
\textframe{TEXT COLOR c\theColor}\par
\textframe{TEXT COLOR c\theColor}\par
\end{document}


