(Novice) Seeking formula to match text color with progress bar

Hi, Im using a multicolor circular battery p-bar, and it has the current charge percentage displayed within it. I was wondering how to use an "if" formula to have the percentage text color produce the same color currently displayed on the progressbar? Simply put, I want to have the text color change with whatever color the progress bar is showing?

This is tricky, you cannot do it natively but you can simulate the same behavior using the CE function and set the gradient to the same value of the progress bar, so something like $ce(COLOR1, COLOR2, PERCENTAGE)$ will go from color1 to 2 according to percentage the same way the progress bar does