It is currently April 19th, 2024, 1:03 pm

Changing Text Colors

Get help with creating, editing & fixing problems with skins
User avatar
Fuzzybat23
Posts: 44
Joined: May 10th, 2013, 1:21 am

Changing Text Colors

Post by Fuzzybat23 »

I have a skin that measures my gpu temp output. I'm trying to get it to change the color of the text in five different stages, based on temperature, only it doesn't seem to be working at all. My text remains at the base color. If anyone can spot where I went wrong, I'd greatly appreciate it :)

Code: Select all

[MeasureGPUTemp]
Measure=Plugin
Plugin=Plugins\MSIAfterburner.dll
Datasource=GPU temperature
MinValue=0
MaxValue=80

[MeasureRange]
Measure=Calc
Formula=(MeasureGPUTemp % 100) +1
MinValue=1
MaxValue=80
IfCondition=TempBarCalc < 30
IfTrueAction=[!RainmeterSetVariable ColorTemp 000, 000, 250][!Redraw]
IfCondition2=(TempBarCalc >= 30) && (TempBarCalc < 35)
IfTrueAction2=[!RainmeterSetVariable ColorTemp 062, 000, 187][!Redraw]
IfCondition3=(TempBarCalc >= 35) && (TempBarCalc < 45)
IfTrueAction3=[!RainmeterSetVariable ColorTemp 125, 000, 125][!Redraw]
IfCondition4=(TempBarCalc >= 45) && (TempBarCalc < 55)
IfTrueAction4=[!RainmeterSetVariable ColorTemp 187, 000, 062][!Redraw]
IfCondition5=(TempBarCalc >= 55)
IfTrueAction5=[!RainmeterSetVariable ColorTemp 250, 000, 000][!Redraw]

[MeterCelcius]
Meter=String
MeasureName=MeasureGPUTemp
NumOfDecimals=0
FontFace=Nasalization Free
FontSize=16
FontColor=#ColorTemp#
Text="%1°C"
x=([Background:x]+61)
y=([MeterGPUText2:y]+42)
StringEffect=None
StringAlign=Center
DynamicVariables=1
AntiAlias=1

User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Changing Text Colors

Post by balala »

Fuzzybat23 wrote:I have a skin that measures my gpu temp output. I'm trying to get it to change the color of the text in five different stages, based on temperature, only it doesn't seem to be working at all. My text remains at the base color. If anyone can spot where I went wrong, I'd greatly appreciate it :)
The main issue is with the !SetVariable bangs. As you wrote them, the used color codes contain spaces and in such cases, they should be included into quotation marks:

Code: Select all

IfCondition=TempBarCalc < 30
IfTrueAction=[!RainmeterSetVariable ColorTemp "0, 0, 250"][!Redraw]
IfCondition2=(TempBarCalc >= 30) && (TempBarCalc < 35)
IfTrueAction2=[!RainmeterSetVariable ColorTemp "62, 0, 187"][!Redraw]
IfCondition3=(TempBarCalc >= 35) && (TempBarCalc < 45)
IfTrueAction3=[!RainmeterSetVariable ColorTemp "125, 0, 125"][!Redraw]
IfCondition4=(TempBarCalc >= 45) && (TempBarCalc < 55)
IfTrueAction4=[!RainmeterSetVariable ColorTemp "187, 0, 62"][!Redraw]
IfCondition5=(TempBarCalc >= 55)
IfTrueAction5=[!RainmeterSetVariable ColorTemp "250, 0, 0"][!Redraw]
Note that in the above code, I also removed the "leading zeros" from the color codes, because they are not needed. Although even if you leave them there, the code will still work, they are useless. The decimal color codes don't need them, just the hex codes do:

Code: Select all

IfCondition=TempBarCalc < 30
IfTrueAction=[!RainmeterSetVariable ColorTemp "0000FA"][!Redraw]
IfCondition2=(TempBarCalc >= 30) && (TempBarCalc < 35)
IfTrueAction2=[!RainmeterSetVariable ColorTemp "3E00BB"][!Redraw]
IfCondition3=(TempBarCalc >= 35) && (TempBarCalc < 45)
IfTrueAction3=[!RainmeterSetVariable ColorTemp "7D007D"][!Redraw]
IfCondition4=(TempBarCalc >= 45) && (TempBarCalc < 55)
IfTrueAction4=[!RainmeterSetVariable ColorTemp "BB003E"][!Redraw]
IfCondition5=(TempBarCalc >= 55)
IfTrueAction5=[!RainmeterSetVariable ColorTemp "FF0000"][!Redraw]
Even if the color codes don't have spaces, they are in fact strings, so you should get to used to use the quotations.

A few more tips:
  • The !Rainmeter... bang prefix is deprecated. Remove them, they are not needed any more.
  • The [TempBarCalc] measure isn't posted. Make sure you have it in your code, because its name is used in the IfCondition options, so, to work properly, the code needs it. On the other hand, if you've used it in the conditions, I'd move these conditions to the [TempBarCalc] measure itself. Although if the measure is properly created the conditions will work, no matter in which measure have you placed them, in my opinion would be more logical to put the conditions into the appropriate measure itself.
  • From the point of view of the code, this definitely doesn't matter, but the name of the [MeterCelcius] meter probably is wrong, it should be [MeterCelsius]. If you'll take a break, then later will come back to your code and will want to continue working on it, this small typo can give you a lot of headache. I'd fix it, to avoid such later problems.
  • Neither this is not a great problem, but the Plugin option of the [MeasureGPUTemp] measure should be written into a more concise form: Plugin=MSIAfterburner, instead of Plugin=[color=#FF0000]Plugins\[/color]MSIAfterburner[color=#FF0000].dll[/color]. It's perfectly enough.