It is currently April 26th, 2024, 12:43 am

Changing a font's color based on the value of a measure

Tips and Tricks from the Rainmeter Community
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Changing a font's color based on the value of a measure

Post by smurfier »

Scolex wrote:A couple of questions;
Does this also work for graphs?
Is there support for more than 2 colors, for example: CPU temp 0-30° = color x, 31-50° = color y, 50°-∞ = color z

I just started using RM today so I have no idea what it's capabilities are. I have started playing around already though and created a skin to utilize the registry entries of Everest Ultimate.
You can either repeat the measure that changes the value of the variable (with a different name and different conditions), or you can use a slightly different method: Changing color with a substitute
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
AcidStrike
Posts: 2
Joined: June 17th, 2010, 5:37 am

Re: Changing a font's color based on the value of a measure

Post by AcidStrike »

I've tried to implement this for quite some time independently of any forum or IRC, but now I've come to the conclusion that I just don't have the ability. So I turn to you.

I'm looking to simply modify the original Enigma System Compact skin to set variable colours for CPU, RAM, and PWR values. So far my code looks like:

Code: Select all

;------------------------------------------------------------------------------------------------
; ENIGMA SYSTEM COMPACT
; Class: Double

[Rainmeter]
Author=Kaelri.LCD@gmail.com
AppVersion=1001000
Update=1000
MiddleMouseDownAction=!RainmeterActivateConfig #CURRENTCONFIG# Compact-Icon.ini

[Metadata]
Name=Enigma System Compact
Config=Enigma | Taskbar | System-Compact
Description=This skin shows your CPU, RAM, hard drive and laptop battery usage.
Version=2.7
Tags=Taskbar | System
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Preview=#SKINSPATH#Enigma\Resources\Images\Preview.png

[Variables]
@include=#SKINSPATH#Enigma\Resources\Variables\UserVariables.inc

DisplayColor=255,255,255,255

;------------------------------------------------------------------------------------------------
; MEASURES

[MeasureCPU]
Measure=CPU
IfAboveValue=50
IfAboveAction=!RainmeterSetVariable DisplayColor 255,0,0,255
IfBelowValue=50
IfBelowAction=!RainmeterSetVariable DisplayColor 255,255,255,255

[MeasureDelayCPU]
Measure=Calc
Formula=MeasureCPU

[MeasureRAM]
Measure=PhysicalMemory

[MeasureHD]
Measure=FreeDiskSpace
Drive=C:

[MeasurePower]
Measure=Plugin
Plugin=Plugins\PowerPlugin.dll
PowerState=PERCENT

;------------------------------------------------------------------------------------------------
; STYLES

[StyleLabel]
FontColor=#Color2#
FontFace=#Font#
FontSize=#Height2#
StringAlign=RIGHT
StringStyle=NORMAL
AntiAlias=1

[StyleText]
FontColor=#Color1#
FontFace=#Font#
FontSize=#Height4#
StringAlign=LEFT
StringStyle=NORMAL
AntiAlias=1
Text="%1"

[StyleTextDynamic]
FontColor=#DisplayColor#
FontFace=#Font#
FontSize=#Height4#
StringAlign=LEFT
StringStyle=NORMAL
AntiAlias=1
Text="%1"

;------------------------------------------------------------------------------------------------
; METERS

[Background]
Meter=Image
SolidColor=0, 0, 0, 2
X=25
Y=0
W=30
H=30

[Label CPU]
Meter=STRING
MeterStyle=StyleLabel
Text="CPU |"
X=45
Y=1

[Label RAM]
Meter=STRING
MeterStyle=StyleLabel
Text="RAM |"
X=r
Y=14r

[Label HDD]
Meter=STRING
MeterStyle=StyleLabel
Text="HDD |"
X=105
Y=1

[Label PWR]
Meter=STRING
MeterStyle=StyleLabel
Text="PWR |"
X=r
Y=14r

[CPU]
Meter=STRING
MeterStyle=StyleTextDynamic
MeasureName=MeasureDelayCPU
X=44
Y=0

[RAM]
Meter=STRING
MeterStyle=StyleText
MeasureName=MeasureRAM
X=r
Y=15r
Percentual=1
AutoScale=1

[HD]
Meter=STRING
MeterStyle=StyleText
MeasureName=MeasureHD
X=104
Y=0
AutoScale=1
NumOfDecimals=0

[Power]
Meter=STRING
MeterStyle=StyleText
MeasureName=MeasurePower
X=r
Y=15r
It seems to be doing nothing. I've been fighting with tons of different possibilities with this, but I can't find a solution. And as of now my mind is too jumbled to think concisely. Thanks for any help! :D
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Changing a font's color based on the value of a measure

Post by smurfier »

AcidStrike wrote:I've tried to implement this for quite some time independently of any forum or IRC, but now I've come to the conclusion that I just don't have the ability. So I turn to you.

I'm looking to simply modify the original Enigma System Compact skin to set variable colours for CPU, RAM, and PWR values. So far my code looks like:

Code: Select all

;------------------------------------------------------------------------------------------------
; ENIGMA SYSTEM COMPACT
; Class: Double

[Rainmeter]
Author=Kaelri.LCD@gmail.com
AppVersion=1001000
Update=1000
MiddleMouseDownAction=!RainmeterActivateConfig #CURRENTCONFIG# Compact-Icon.ini

[Metadata]
Name=Enigma System Compact
Config=Enigma | Taskbar | System-Compact
Description=This skin shows your CPU, RAM, hard drive and laptop battery usage.
Version=2.7
Tags=Taskbar | System
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Preview=#SKINSPATH#Enigma\Resources\Images\Preview.png

[Variables]
@include=#SKINSPATH#Enigma\Resources\Variables\UserVariables.inc

DisplayColor=255,255,255,255

;------------------------------------------------------------------------------------------------
; MEASURES

[MeasureCPU]
Measure=CPU
IfAboveValue=50
IfAboveAction=!RainmeterSetVariable DisplayColor 255,0,0,255
IfBelowValue=50
IfBelowAction=!RainmeterSetVariable DisplayColor 255,255,255,255

[MeasureDelayCPU]
Measure=Calc
Formula=MeasureCPU

[MeasureRAM]
Measure=PhysicalMemory

[MeasureHD]
Measure=FreeDiskSpace
Drive=C:

[MeasurePower]
Measure=Plugin
Plugin=Plugins\PowerPlugin.dll
PowerState=PERCENT

;------------------------------------------------------------------------------------------------
; STYLES

[StyleLabel]
FontColor=#Color2#
FontFace=#Font#
FontSize=#Height2#
StringAlign=RIGHT
StringStyle=NORMAL
AntiAlias=1

[StyleText]
FontColor=#Color1#
FontFace=#Font#
FontSize=#Height4#
StringAlign=LEFT
StringStyle=NORMAL
AntiAlias=1
Text="%1"

[StyleTextDynamic]
FontColor=#DisplayColor#
FontFace=#Font#
FontSize=#Height4#
StringAlign=LEFT
StringStyle=NORMAL
AntiAlias=1
Text="%1"
DynamicVariables=1

;------------------------------------------------------------------------------------------------
; METERS

[Background]
Meter=Image
SolidColor=0, 0, 0, 2
X=25
Y=0
W=30
H=30

[Label CPU]
Meter=STRING
MeterStyle=StyleLabel
Text="CPU |"
X=45
Y=1

[Label RAM]
Meter=STRING
MeterStyle=StyleLabel
Text="RAM |"
X=r
Y=14r

[Label HDD]
Meter=STRING
MeterStyle=StyleLabel
Text="HDD |"
X=105
Y=1

[Label PWR]
Meter=STRING
MeterStyle=StyleLabel
Text="PWR |"
X=r
Y=14r

[CPU]
Meter=STRING
MeterStyle=StyleTextDynamic
MeasureName=MeasureDelayCPU
X=44
Y=0

[RAM]
Meter=STRING
MeterStyle=StyleText
MeasureName=MeasureRAM
X=r
Y=15r
Percentual=1
AutoScale=1

[HD]
Meter=STRING
MeterStyle=StyleText
MeasureName=MeasureHD
X=104
Y=0
AutoScale=1
NumOfDecimals=0

[Power]
Meter=STRING
MeterStyle=StyleText
MeasureName=MeasurePower
X=r
Y=15r
It seems to be doing nothing. I've been fighting with tons of different possibilities with this, but I can't find a solution. And as of now my mind is too jumbled to think concisely. Thanks for any help! :D
Wherever you use the variable whose value you changed, you need to add DynamicVariables=1, otherwise that measure or meter only sees the original value.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing a font's color based on the value of a measure

Post by jsmorley »

smurfier wrote: Wherever you use the variable whose value you changed, you need to add DynamicVariables=1, otherwise that measure or meter only sees the original value.
He is. He has the DynamicVariables=1 in the MeterStyle he is using in the meters he wants to have dynamic colors.

So Acid, I don't see the issue? It works fine for me on CPU. If it goes above 50, the color changes to red. Below 50, it's white. What specifically are you having trouble with? You just need to extend the thinking you have in place for CPU to the the other things like RAM if you want.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Changing a font's color based on the value of a measure

Post by smurfier »

I added it when I pressed the quote button.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing a font's color based on the value of a measure

Post by jsmorley »

smurfier wrote:I added it when I pressed the quote button.
Ah. I see. If I directly change or add something in someone else's quote, I generally make my change a different color, but in any case you are right and that should fix it for him.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Changing a font's color based on the value of a measure

Post by smurfier »

That would probably be a good idea, but I'm pretty lazy.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing a font's color based on the value of a measure

Post by jsmorley »

smurfier wrote:That would probably be a good idea, but I'm pretty fat, stupid and lazy.
Fair enough.. ;-) There is always a risk when changing someone else's direct quote without making it clear that you did so. See above...
User avatar
wiedzmawiedzma
Posts: 112
Joined: August 18th, 2012, 5:19 pm

Re: Changing a font's color based on the value of a measure

Post by wiedzmawiedzma »

And what solution Delay display number one cycle could be used when you do not use IfAboveAction and IfBelowAction just such a solution color change :

Code: Select all

[Rainmeter]
Update=2000
Author=WiedzmaWiedzma 
DynamicWindowSize=1

[Variables]
font.color.Process1=[MeasureColor1]

[CPUUsageCalc]
Measure=Calc
Formula=MeasureProcess1/200000
MinValue=0
MaxValue=100

[MeasureColor1]
Measure=Calc
Formula=(CPUUsageCalc < 60 ? -1 : (CPUUsageCalc < 80 ? -2 : -3))
Substitute="-1":"7b7b7b", "-2":"979e2d", "-3":"9e2d2d"

[TextStyle]
FontFace=Segoe UI
StringStyle=BOLD
FontSize=7
AntiAlias=1

;Process1---------------------------------

[MeasureProcess1]
Measure=Plugin
Plugin=AdvancedCPU
TopProcess=1
CPUExclude=Idle


[MeasureProcess1Name]
Measure=Plugin
Plugin=AdvancedCPU
TopProcess=2
CPUExclude=Idle

[MeterProcess1]
Meter=STRING
MeterStyle=TextStyle
fontColor=#font.color.Process1#
MeasureName=MeasureProcess1
MeasureName2=MeasureProcess1Name
X=5
Y=29
Text="- %2"
NumOfDecimals=1
DynamicVariables=1
Scale=200000

[MeterProcess1%]
Meter=STRING
StringAlign=Right
MeterStyle=TextStyle
fontColor=#font.color.Process1#
MeasureName=MeasureProcess1
MeasureName2=MeasureProcess1Name
X=160
Y=29
Text="%1%"
NumOfDecimals=1
DynamicVariables=1
Scale=200000 
User avatar
wiedzmawiedzma
Posts: 112
Joined: August 18th, 2012, 5:19 pm

Re: Changing a font's color based on the value of a measure

Post by wiedzmawiedzma »

The question is not valid now noticed a post
Rainmeter 2.3 fix for "delay" issue http://rainmeter.net/forum/viewtopic.php?f=15&t=11233 :welcome: