Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1970

Help: Rainmeter Skins • Re: [Resolved] Bar that changes color based on variable.

$
0
0
I'm so confused with how to use conditional in Rainmeter.

Note: There is bar for each CPU thread. If there is a more performant way to do this please let me know too.
[...]
First try: This gave the bar a weird color. It's a color that I never declare or wrote anywhere in the script. Which is CYAN.

Code:

[Variables]MyAccentColorOpaque=131,192,239MyDarkAccentColorOpaque=200,60,77TheirAccentColor=#MyAccentColorOpaque#,255TheirDarkAccentColor=#MyDarkAccentColorOpaque#,255[CsCpuThrottle]Measure=CalcFormula=1[tCpu1]Meter=BARMeasureName=sCpu1X=#MySectionSpacing#RY=#MyMarginTop#W=#MyBarWidth#H=#MyHeight#BarColor=([CsCpuThrottle] == 0 ? #TheirAccentColor# : #TheirDarkAccentColor#)DynamicVariables=1SolidColor=#MyBarBackground#BarOrientation=Vertical
Didn't read all the details in the thread, but here is a very simple solution, if the value of [CsCpuThrottle] is one in a limited set of numbers (e.g. 0 or 1; 0 or 1 or 2; etc.) - no conditional, no IfConditions, just nested syntax for variables:

Code:

[Variables]MyAccentColorOpaque=131,192,239MyDarkAccentColorOpaque=200,60,77TheirAccentColor=#MyAccentColorOpaque#,255TheirDarkAccentColor=#MyDarkAccentColorOpaque#,255SomeColor0=#TheirAccentColor#SomeColor1=#TheirDarkAccentColor#[CsCpuThrottle]Measure=CalcFormula=1[tCpu1]Meter=BARMeasureName=sCpu1X=#MySectionSpacing#RY=#MyMarginTop#W=#MyBarWidth#H=#MyHeight#BarColor=[#SomeColor[&CsCpuThrottle]]DynamicVariables=1SolidColor=#MyBarBackground#BarOrientation=Vertical
Basically, you can use the value of [CsCpuThrottle] as part of the name of a SomeColorN variable in the BarColor option from [tCpu1].

This assumes that when [CsCpuThrottle] is updated, [tCpu1] is updated as well (and the skin redrawn, of course), either automatically via the skin's Update option from its [Rainmeter] section, or manually via the corresponding bangs if that measure is itself manually updated.

P.S. Or, you could just rename TheirAccentColor and TheirDarkAccentColor to blabla0 and blabla1 and use the latter instead, if you don't want two additional variables in the code.

Statistics: Posted by Yincognito — Today, 8:41 am



Viewing all articles
Browse latest Browse all 1970

Trending Articles