One of the things that comes up from time to time is how to change the color of a String meter "behind" a Bar meter as the bar progresses. An example might be the best way to visualize this:
Anim1.gif
This can be done with a bit of math to figure out the relationship between the String meter's X position and the end of the Bar meter's progression, and using InlineSetting to set a GradientColor on the text.
The key to this is that the X position of the String meter must be set with a formula to center it in the width of the Bar meter, one that dynamically uses its own width in the formula. That is because we have to "know" the X position of the String meter, and using W and X and StringAlign=Center or StringAlign=Right won't allow you to know that on a variable length string without being one update behind.
Re: Changing text color behind a bar meter
Posted: February 15th, 2016, 8:31 pm
by Active Colors
Very astute technique. Impressive!
Re: Changing text color behind a bar meter
Posted: February 15th, 2016, 9:18 pm
by balala
Indeed a nice piece of code. Congratulations, FreeRaider!
Re: Changing text color behind a bar meter
Posted: February 15th, 2016, 9:55 pm
by FreeRaider
Active Colors, balala, thank you so much.
Re: Changing text color behind a bar meter
Posted: August 15th, 2017, 10:01 am
by StArL0rd84
Very nice
At first i couldn't figure out why nothing was showing when i tried the example code.
Turns out both MeterBar and MeterString had H=([MeterString:H]) set.
Re: Changing text color behind a bar meter
Posted: August 19th, 2020, 2:35 am
by Yincognito
I don't mean to take out credit from the ingenious solution of FreeRaider, but just for the sake of being up to date with "modern" Rainmeter, this can be done now using the text as a Container meter masking a second bar as well:
Containers are in top 5 Rainmeter features, in my view.
Re: Changing text color behind a bar meter
Posted: August 19th, 2020, 3:02 am
by jsmorley
Yeah, Container makes this a bunch easier...
And yes, I LOVE Container. It has the absolute beauty of "simplicity" combined with "power" that is so rare.
Re: Changing text color behind a bar meter
Posted: August 24th, 2020, 11:18 am
by FreeRaider
Yincognito wrote: ↑August 19th, 2020, 2:35 am
I don't mean to take out credit from the ingenious solution of FreeRaider, but just for the sake of being up to date with "modern" Rainmeter, this can be done now using the text as a Container meter masking a second bar as well: