It is currently March 29th, 2024, 7:45 am

FontColor Formula

Report bugs with the Rainmeter application and suggest features.
User avatar
mmxiv
Posts: 18
Joined: February 14th, 2021, 5:48 pm

FontColor Formula

Post by mmxiv »

Hello. I wonder do you plan to add formula support to the FontColor option?
I think it would be a very sweet addition.
I'd like to easily change colors in FontColor depending on a variable. It would be much easier than making additional measure(s) just for it.

For instance:

Code: Select all

Variables
State=1
Color1=0,200,100
Color2=0,0,0

[Meter1]
Meter=String
...
FontColor=((#State#=1) ? #Color1# : #Color2#)
Last edited by balala on May 22nd, 2021, 6:25 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are posting code snippets. It's the </> button.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: FontColor Formula

Post by SilverAzide »

mmxiv wrote: May 21st, 2021, 11:34 pm Hello. I wonder do you plan to add formula support to the FontColor option?
I think it would be a very sweet addition.
I'd like to easily change colors in FontColor depending on a variable. It would be much easier than making additional measure(s) just for it.
This is already possible. You just need to tweak your logic slightly. To use formulas with colors, you simply have a formula for each color (and alpha, if you want).

Code: Select all

FontColor=(RedFormula),(GreenFormula),(BlueFormula),(AlphaFormula)
Gadgets Wiki GitHub More Gadgets...
User avatar
mmxiv
Posts: 18
Joined: February 14th, 2021, 5:48 pm

Re: FontColor Formula

Post by mmxiv »

SilverAzide wrote: May 22nd, 2021, 2:23 am This is already possible. You just need to tweak your logic slightly. To use formulas with colors, you simply have a formula for each color (and alpha, if you want).

Code: Select all

FontColor=(RedFormula),(GreenFormula),(BlueFormula),(AlphaFormula)
I ain't sure how to use this method in a simple way.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: FontColor Formula

Post by death.crafter »

mmxiv wrote: May 22nd, 2021, 9:38 am I ain't sure how to use this method in a simple way.
FontColor=((condition) ? [#R1] : [#R2]), ((condition) ? [#G1] : [#G2]), ((condition) ? [#B1] : [#B2]), ((condition) ? [#A1] : [#A2])

RGBA stand for Red, Green, Blue, Alpha here
from the Realm of Death
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: FontColor Formula

Post by balala »

mmxiv wrote: May 21st, 2021, 11:34 pm Hello. I wonder do you plan to add formula support to the FontColor option?
I think it would be a very sweet addition.
I'd like to easily change colors in FontColor depending on a variable. It would be much easier than making additional measure(s) just for it.
This is not possible (and I suppose it won't be in the futher either), because all formulas (doesn't matter if they are applied on Formula options of Calc measures, on Ifcondition options of any kind of measures or on other type of options) have to be entirely numeric. As such, they can't work with strings. Now a color code is always a string, even if it is composed by three or four numbers. A number can't contain a comma, even less more of them, so a color code is a string, which can't be used in formulas.
The solution is either the one described above by SilverAzide and death.crafter or an additional Measure, which will set the color through !SetOption or !SetVariable bangs (yes, I realized you'd like to avoid adding additional measures, but that's it).