It is currently December 3rd, 2022, 11:42 am

Change Color on Certain Seconds

Get help with creating, editing & fixing problems with skins
jasonvertez
Posts: 6
Joined: October 28th, 2022, 10:13 pm

Change Color on Certain Seconds

Post by jasonvertez »

Hello everyone,

I'm trying to make a Digital Clock for my work. My job is a very time-based field (from second-to-second), so it is critical for me to make sure I get this right.

I tried creating a clock that changes colors from xx:xx:00 to xx:xx:15. From #00ff00(green), to it's lightest tint variation of #ebffeb. Then from xx:xx:16 to xx:xx:46, it'll be white, aka #ffffff. From xx:xx:47 to xx:xx:59, to make the clock go from #ffebeb to #ff0000(red).

Color hex references(seek 'shades and tints of #xxxxxx') of green to white and white to red:

https://www.colorhexa.com/00ff00
https://www.colorhexa.com/ff0000

I am trying to make it so that only the SECONDS ( %s string) changes color, and not the entire time (%H and %M). I'd like for the hour and minute to remain ffffff white.

I also am trying to make one for the 5 minute increments, but only from 30 to 45 minutes being green, while 45 to 0 is yellow, and 1 to 15 is red, similar tinting to the hex colors above.

The code I currently am running seems to work for only a second. I'm not sure what I did wrong here. After a minute, it changes to the last TrueAction / TrueCondition (28), and doesn't seem to change.

Here's the code:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureSecond]
Measure=Time
Format=%#S
IfCondition=(MeasureSecond >= 1) || (MeasureSecond < 2)
IfTrueAction=[!SetVariable TextColor "20,255,20,255"][!UpdateMeter *][!Redraw]
IfCondition2=(MeasureSecond >= 2) || (MeasureSecond < 3)
IfTrueAction2=[!SetVariable TextColor "39,255,39,255][!UpdateMeter *][!Redraw]
IfCondition3=(MeasureSecond >= 3) || (MeasureSecond < 4)
IfTrueAction3=[!SetVariable TextColor "59,255,59,255"][!UpdateMeter *][!Redraw]
IfCondition4=(MeasureSecond >= 4) || (MeasureSecond < 5)
IfTrueAction4=[!SetVariable TextColor "78,255,78,255"][!UpdateMeter *][!Redraw]
IfCondition5=(MeasureSecond >= 5) || (MeasureSecond < 6)
IfTrueAction5=[!SetVariable TextColor "98,255,98,255"][!UpdateMeter *][!Redraw]
IfCondition6=(MeasureSecond >= 6) || (MeasureSecond < 7)
IfTrueAction6=[!SetVariable TextColor "118,255,118,255"][!UpdateMeter *][!Redraw]
IfCondition7=(MeasureSecond >= 7) || (MeasureSecond < 8)
IfTrueAction7=[!SetVariable TextColor "137,255,137,255"][!UpdateMeter *][!Redraw]
IfCondition8=(MeasureSecond >= 8) || (MeasureSecond < 9)
IfTrueAction8=[!SetVariable TextColor "157,255,157,255"][!UpdateMeter *][!Redraw]
IfCondition9=(MeasureSecond >= 9) || (MeasureSecond < 10)
IfTrueAction9=[!SetVariable TextColor "177,255,177,255"][!UpdateMeter *][!Redraw]
IfCondition10=(MeasureSecond >= 10) || (MeasureSecond < 11)
IfTrueAction10=[!SetVariable TextColor "196,255,196,255"][!UpdateMeter *][!Redraw]
IfCondition11=(MeasureSecond >= 11) || (MeasureSecond < 12)
IfTrueAction11=[!SetVariable TextColor "216,255,216,255"][!UpdateMeter *][!Redraw]
IfCondition12=(MeasureSecond >= 12) || (MeasureSecond < 13)
IfTrueAction12=[!SetVariable TextColor "235,255,235,255"][!UpdateMeter *][!Redraw]
IfCondition13=(MeasureSecond >= 13) || (MeasureSecond < 14)
IfTrueAction13=[!SetVariable TextColor "255,255,255,255"][!UpdateMeter *][!Redraw]
IfCondition14=(MeasureSecond >= 14) || (MeasureSecond < 15)
IfTrueAction14=[!SetVariable TextColor "255,255,255,255"][!UpdateMeter *][!Redraw]
IfCondition15=(MeasureSecond >= 15) || (MeasureSecond < 45)
IfTrueAction15=[!SetVariable TextColor "255,255,255,255"][!UpdateMeter *][!Redraw]
IfCondition16=(MeasureSecond >= 47) || (MeasureSecond < 48)
IfTrueAction16=[!SetVariable TextColor "255,235,235,255"][!UpdateMeter *][!Redraw]
IfCondition17=(MeasureSecond >= 48) || (MeasureSecond < 49)
IfTrueAction17=[!SetVariable TextColor "255,216,216,255"][!UpdateMeter *][!Redraw]
IfCondition18=(MeasureSecond >= 49) || (MeasureSecond < 50)
IfTrueAction18=[!SetVariable TextColor "255,196,196,255"][!UpdateMeter *][!Redraw]
IfCondition19=(MeasureSecond >= 50) || (MeasureSecond < 51)
IfTrueAction19=[!SetVariable TextColor "255,177,177,255"][!UpdateMeter *][!Redraw]
IfCondition20=(MeasureSecond >= 51) || (MeasureSecond < 52)
IfTrueAction20=[!SetVariable TextColor "255,157,157,255"][!UpdateMeter *][!Redraw]
IfCondition21=(MeasureSecond >= 52) || (MeasureSecond < 53)
IfTrueAction21=[!SetVariable TextColor "255,137,137,255"][!UpdateMeter *][!Redraw]
IfCondition22=(MeasureSecond >= 53) || (MeasureSecond < 54)
IfTrueAction22=[!SetVariable TextColor "255,118,118,255"][!UpdateMeter *][!Redraw]
IfCondition23=(MeasureSecond >= 54) || (MeasureSecond < 55)
IfTrueAction23=[!SetVariable TextColor "255,98,98,255"][!UpdateMeter *][!Redraw]
IfCondition24=(MeasureSecond >= 55) || (MeasureSecond < 56)
IfTrueAction24=[!SetVariable TextColor "255,78,78,255"][!UpdateMeter *][!Redraw]
IfCondition25=(MeasureSecond >= 56) || (MeasureSecond < 57)
IfTrueAction25=[!SetVariable TextColor "255,59,59,255"][!UpdateMeter *][!Redraw]
IfCondition26=(MeasureSecond >= 57) || (MeasureSecond < 58)
IfTrueAction26=[!SetVariable TextColor "255,39,39,255"][!UpdateMeter *][!Redraw]
IfCondition27=(MeasureSecond >= 58) || (MeasureSecond < 59)
IfTrueAction27=[!SetVariable TextColor "255,20,20,255"][!UpdateMeter *][!Redraw]
IfCondition28=(MeasureSecond >= 59) || (MeasureSecond < 0)
IfTrueAction28=[!SetVariable TextColor "255,255,255,255"][!UpdateMeter *][!Redraw]
DynamicVariables=1

[MeasureTime]
Measure=Time
Format=%#I:%M:%S

[MeterTime]
Meter=String
MeasureName=MeasureTime
Y=0R
FontSize=30
FontColor=#TextColor#
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
I know operators exist, but I'm quite a noob at rainmeter's language (I only started ~2 weeks ago). If this would be animated (like a gradual transition), that would be even better, but I know that takes a lot of time to do.

Any advice, I'd be ever so grateful!
Thank you so much in advance! :)
Last edited by jasonvertez on November 16th, 2022, 7:21 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 14758
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Color on Certain Seconds

Post by balala »

jasonvertez wrote: November 16th, 2022, 5:50 pm The code I currently am running seems to work for only a second. I'm not sure what I did wrong here. After a minute, it changes to the last TrueAction / TrueCondition (28), and doesn't seem to change.
The IfConditions are a little bit wrong. All IfConditions are always true, excepting the last one, which is true only when second is 59. For instance, the first condition: IfCondition=(MeasureSecond >= 1) || (MeasureSecond < 2) is true when the second is above or equal to 1 OR it's below 2. But this is always true, no matter what second the measure is returning. The solution is to replace the || operator with && in all IfConditions, excepting the last one (IfCondition28), where the || operator is ok:

Code: Select all

[MeasureSecond]
...
IfCondition=((MeasureSecond >= 1) && (MeasureSecond < 2))
...
IfCondition2=((MeasureSecond >= 2) && (MeasureSecond < 3))
...
IfCondition3=((MeasureSecond >= 3) && (MeasureSecond < 4))
...
IfCondition4=((MeasureSecond >= 4) && (MeasureSecond < 5))
...
IfCondition5=((MeasureSecond >= 5) && (MeasureSecond < 6))
...
IfCondition6=((MeasureSecond >= 6) && (MeasureSecond < 7))
...
...
...
IfCondition28=((MeasureSecond >= 59) || (MeasureSecond < 0))
...
Obviously I posted only the first six IfConditions and the last one, but all others have to be modified in the same way.
Note that besides replacing the operators, I also added brackets around the whole conditions. This is not mandatory, but is preferable.
jasonvertez
Posts: 6
Joined: October 28th, 2022, 10:13 pm

Re: Change Color on Certain Seconds

Post by jasonvertez »

balala wrote: November 16th, 2022, 6:49 pm
I see!

It was a simple logical operator error on my behalf. I did not realize that && meant AND, and || meant OR. It's not meant to be either, or. But instead, it is meant to be both, and to continue the transition.

So basically (MeasureSecond >= 1) AND (MeasureSecond < 2), not (MeasureSecond >= 1) OR (MeasureSecond < 2). That makes sense.

What you replied worked exactly as I was hoping. :)

Next time I need to read the references on rainmeter... I still have yet to do that.

Thank you so much, Balala!
User avatar
balala
Rainmeter Sage
Posts: 14758
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Color on Certain Seconds

Post by balala »

jasonvertez wrote: November 16th, 2022, 7:20 pm So basically (MeasureSecond >= 1) AND (MeasureSecond < 2), not (MeasureSecond >= 1) OR (MeasureSecond < 2).
Exactly. However I'd be tempted to use a much simpler form of these conditions. For instance replacing the IfCondition=(MeasureSecond >= 1) || (MeasureSecond < 2) condition with IfCondition=(MeasureSecond=1), IfCondition2=(MeasureSecond >= 2) || (MeasureSecond < 3) with IfCondition2=(MeasureSecond=2) and so on, up to IfCondition14. There is nothing you can do in this sense with IfCondition15, but then you can apply the same thing to all conditions from IfCondition17 to IfCondition27 again. This simplifies a little bit the code.
jasonvertez wrote: November 16th, 2022, 7:20 pm Next time I need to read the references on rainmeter... I still have yet to do that.
We all have to.
jasonvertez wrote: November 16th, 2022, 7:20 pm Thank you so much, Balala!
You're welcome. Glad to help.